TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: FRANK MASINGILL
date: 1997-05-26 04:52:00
subject: getline?

    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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.