101
{ USER }
posts: 55
last: 09-Apr-2008
TITLE: File example using fstream functions
DESCRIPTION: File example using fstream header functions
Submitted: 09-Apr-2008 08:05:39 ( 21w 5d 2h ago ) Language: C++ (*.cpp *.h)
Views: 195 Lines of Code: 26 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 0.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 101
   Date: 09-04-2008
   Filename: 
   Description: File example using fstream.h functions
   History: 
*/


#include<iostream.h>
#include<fstream.h> 
int main()

{
// first lets output to a file
ofstream fout("sample.txt");
fout << "WWW" << 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;
}