Page 1 of 1

End of Line in C/C++

Posted: Mon Jan 05, 2004 10:14 am
by Verdan
Hello!
Can you tell me, how can I check if there is EOLN (End Of LiNe (like in Pascal)) while reading from input.


Something like:
[pascal]
While Not EOLN(input) do
read(i);
[/pascal]

Posted: Tue Jan 06, 2004 12:55 am
by Krzysztof Duleba
For instance, you can save the line in a string and then parse it. All you need is to include <string> and <iostream> and then write
[cpp]string line;
getline(cin,line);[/cpp]
If you want to parse with a stringstream, add
[cpp]#include <sstream>[/cpp]

An easy way

Posted: Thu Jan 08, 2004 7:12 am
by Miguel Angel
[cpp]
while (cin.peek()!='\n')
[/cpp]

Posted: Fri Feb 20, 2004 12:06 pm
by Verdan
Thank you very much!