/**
* Here's a code on how to read data from a file
* Assume your named file is: hello.txt
* Luna Denpasar 24
* Read more: http://www.fredosaurus.com/notes-cpp/io/readtextfile.html
* Read more: http://www.fredosaurus.com/notes-cpp/io/readtextfile.html
*/
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
typedef struct{
string name;
string city;
int age;
}data;
int main(int argc, char* argv[]){
system("color 2f");
ifstream infile("e:/lola/hello.txt");
data you;
infile >> you.name >> you.city >> you.age;
cout << "Name: " << you.name << endl;
cout << "City: " << you.city << endl;
cout << "Age: " << you.age << endl;
return 0;
}
#include <cstdlib>
#include <fstream>
using namespace std;
typedef struct{
string name;
string city;
int age;
}data;
int main(int argc, char* argv[]){
system("color 2f");
ifstream infile("e:/lola/hello.txt");
data you;
infile >> you.name >> you.city >> you.age;
cout << "Name: " << you.name << endl;
cout << "City: " << you.city << endl;
cout << "Age: " << you.age << endl;
return 0;
}
No comments:
Post a Comment