What is wrong with my code below:
Program to send text to a file:
#include
void main()
{
ofstream OutFile("MYTEST.DAT");
OutFile << "This is line 1.\n";
OutFile << "This is line 2.\n";
}
Program to READ text from the file:
#include
void main()
{
const int MAX = 80;
char buffer[MAX];
ifstream InFile("MYTEST.DAT");
while (InFile)
{
InFile.getline(buffer, MAX);
cout << buffer;
}
}
Instead of the expected result of the second file reading in the two
lines as separate lines it is being read in as merged into one line. What am
I doing wrong?
Sincerely,
Frank
--- FMail/386 1.02
---------------
* Origin: Maybe in 5,000 years frankmas@juno.com (1:396/45.12)
|