Categories

Another file example

#include
#include

int main()

{
// first lets output to a file
ofstream fout(“sample.txt”);
fout << "programmershelp" << endl;
fout.close();
char str[20];
//read in the file
ifstream fin(“sample.txt”);
fin >> str;
fin.close();
//display sample.txt contents
cout << "data read from file: " << str << endl;
return 0;
}

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

You must be logged in to post a comment.