reading until EOF

Discussion on C, C++ and C++11 at the COJ. This is the place to clear your doubts about these languages, and to share with the community the new things you learn about them.
Post Reply
Spartan
Posts: 11
Joined: 6 years ago
Gender: None specified

reading until EOF

Post by Spartan » 5 years ago

how can i read until EOF using cin, or any other way different than while( scanf("%s", cadena)!= EOF ). The objective is to use the string of the class string and read with iostream.



User avatar
ymondelo20
Posts: 1968
Joined: 6 years ago
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: reading until EOF

Post by ymondelo20 » 5 years ago

while( cin>>dato )
{
//Do something ...
}

or

while( gets ( line ) )
{
//Do something ...
}
"Every problem has a simple, fast and wrong solution" OJ's Main Law. ;)

Post Reply

Return to “C/C++/C++11”