Multi-line File streaming
Okay, here is the problem:
I want to open a file with the code:
Code:
#include <fstream.h>
int main()
{
ofstream print; // stream variable declaration
print.open("LPT1"); // open stream
// Print Text (the character ‘\f’ will produce a form feed)
print << "This text will print on the printer.\f";
print.close(); // close stream
return 0;
}
(written from another Post here, cant remember from who, sorry ILL FIND OUT NOW!)
and I want to print it onto the screen
The file is called text.txt
Here is the code I use now:
Code:
#include <iostream.h>
#include <fstream.h>
int main()
{
char str[300];
ifstream a_file("text.txt");
a_file>>str;
cout<<str<<endl;
a_file.close();
return 0;
}
When I execute the program all it has is
#include
Someone plz help me