TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: CLIFF RHODES
from: FRANK MASINGILL
date: 1997-05-26 13:07:00
subject: getline?

 > FM>void main()
 > Frank, please use int main(void) !!!!
    Thanks, Cliff, I will.  But WHY do the books I'm following not use it?  
They are some of the most promient names like Lafore, etc.  I'm not implying 
that means they are right - just asking why you make a point of it?
 > FM>        InFile.getline(buffer, MAX);
 > FM>        cout << buffer;
 > FM>    Instead of the expected result of the second file
 > FM>reading in the two lines as separate lines it is being read
 > FM>in as merged into one line.  What am I doing wrong?
 > getline() removes the '\n' at the end of the line--it doesn't
 > store it
 > in buffer. So, when you display buffer you don't get the
 > newline.
 > Use cout << buffer << '\n';
    O.K.  I was  following Lafore _Object Oriented Programming in Turbo C++_, 
Chapter 14, page 523 and he said the getline function read the characters UP 
TO the newline character and failed to say it "removes it"  I added the code 
you instructed and, of course, it worked - and I learned something.
    Thanks "teach" (grin)
                            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™.