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.
Spartan
Posts: 11
Joined: Thu Apr 05, 2012 9:36 pm
Gender: None specified

reading until EOF

Postby Spartan » Fri May 10, 2013 11:45 pm

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
COJ Administrator
Posts: 1968
Joined: Sun Nov 13, 2011 12:32 pm
Location: Universidad de las Ciencias Informáticas
Gender: None specified
Contact:

Re: reading until EOF

Postby ymondelo20 » Sat May 11, 2013 12:00 am

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

or

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


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

Who is online

Users browsing this forum: No registered users and 1 guest