You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
303 B
C++
19 lines
303 B
C++
5 years ago
|
Open a file and display contents on the screen
|
||
|
|
||
|
//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;
|
||
|
}
|