|
-
December 2nd, 2012, 11:37 AM
#4
Re: cin and unknown number of integers
 Originally Posted by tuli
I`d still love to know what i can do in such a case, except for parsing the input char by char. 
you can use getline and stringstream, or something like this to avoid excessive copying:
Code:
std::ifstream file /* = ... */;
std::vector<int> ints;
for( int val; file >> val; )
{
ints.push_back( val );
if( file.peek() == '\n' )
{
do_something_on( ints );
ints.clear();
}
}
but there are also boost iostream, boost serialization, regex's, etc ... etc ...
Last edited by superbonzo; December 2nd, 2012 at 11:39 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|