Categories

A file example

#include
#include
const char *FILENAME = “myfile.txt”;

int main()
{
//create output object associated w/ file
ofstream fout(FILENAME);
cout << "Enter your text: ";
char str[100];
cin >> str;
//write the text to the file
fout << "here is your textn";
fout < //close file
fout.close();

ifstream fin(FILENAME);
char ch;
while (fin.get(ch))
cout << ch;
fin.close();
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.