101
{ USER }
posts: 55
last: 09-Apr-2008
TITLE: Output the contents of a text file
DESCRIPTION: Open a file and display contents on the screen
Submitted: 09-Apr-2008 08:28:17 ( 38w 6d 0h ago ) Language: C++ (*.cpp *.h)
Views: 73 Lines of Code: 25 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 4.00 / 5 }
Difficulty: Intermediate
Bookmark
/* Author: 101
   Date: 09-04-2008
   Filename: 
   Description: Open a file and display contents on the screen
   History: 
*/



//this example opens a file called myfile.txt
//and reads the text message to it
#include <fstream.h> 
int main()
{
ifstream MyFile("myfile.txt");
char ch;

while(!MyFile.eof())
{
MyFile.get (ch);
cout<<ch;
}
MyFile.close();
return 0;
}