| | |
Explain the the problem for me. plzz..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
It's a WRONG attempt to eat the rest of input line on cin (for example, you get the 1st word and you want to skip other stuff).
if cin is attached to a file (not to console), you may get cin.eof condition before '\n' so you never get '\n' in these two lines of code.
Right solution (one of);
if cin is attached to a file (not to console), you may get cin.eof condition before '\n' so you never get '\n' in these two lines of code.
Right solution (one of);
C++ Syntax (Toggle Plain Text)
while (cin && cin.get() != '\n') continue; // or simple while (cin && cin.get() != '\n') ;
•
•
•
•
It's a WRONG attempt to eat the rest of input line on cin (for example, you get the 1st word and you want to skip other stuff).
if cin is attached to a file (not to console), you may get cin.eof condition before '\n' so you never get '\n' in these two lines of code.
Right solution (one of);
C++ Syntax (Toggle Plain Text)
while (cin && cin.get() != '\n') continue; // or simple while (cin && cin.get() != '\n') ;
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Aug 2008
Posts: 15
Reputation:
Solved Threads: 2
Hi,
I am Rammohan from Bangalore and working as a Technical lead in big IT firm .
Solution for your answer is follows:
The Syntax of the snippet code is 100% correct.
It mean that continue your while loop until the input reaches to the next line...
If you press enter key In your input stream then the loop will come out otherwise it will contnue....
Regards,
Rammohan Alampally,
<snip false signature>
I am Rammohan from Bangalore and working as a Technical lead in big IT firm .
Solution for your answer is follows:
The Syntax of the snippet code is 100% correct.
It mean that continue your while loop until the input reaches to the next line...
If you press enter key In your input stream then the loop will come out otherwise it will contnue....
Regards,
Rammohan Alampally,
<snip false signature>
Last edited by Ancient Dragon; Aug 21st, 2008 at 7:39 am. Reason: snip false signature
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: help implementing singly linked list
- Next Thread: Differences Between Java and C/C++
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






