TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: FRANK MASINGILL
from: CAMERON CLARK
date: 1997-05-27 12:52:00
subject: Re: getline?

FM>     Instead of the expected result of the second file reading in the two 
li
FM> as separate lines it is being read in as merged into one line.  What am I
FM> doing wrong?
    It's not. (See the correction below)
FM> #include 
FM> void main()
FM> {
FM>     const int MAX = 80;
FM>     char buffer[MAX];
FM>     ifstream InFile("MYTEST.DAT");
FM>     while (InFile)
FM>     {
FM>         InFile.getline(buffer, MAX);
FM>         cout << buffer;
            cout << endl;
FM>     }
FM> }
    getline() gets up to MAX characters or until it hits a newline character.
    the newline character is _not_ placed into the buffer. your program is
    not merging the two lines, it just writes them on the same line.
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)

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™.