Reputation: 31
So I have a ASCII file that is supposed to begin with 2 characters a 'P' and a '2' nothing preceding and some form of white space after.
The trouble I'm having is testing an error case where there is white space preceding, I'm using a stringstream since the rest of the task requires similar operations and the rest works fine.
The issue I'm having is extracting white that leads, I know by default the extraction operator has the skipws flag set, so I tried turning the noskipws flag on with no success.
Here are a few things I've tried.
The file is ASCII and begins as such
// Imagine there is a space before the P
function(stringstream *pstream) {
char test;
(*pstream).get(test); //This will put the character P in test
(*pstream) >> noskipws >> test; //This does the same thing
}
Simple question really how do I not ignore the whitespace while extracting using stringstream preferably since there is more i have to do with stream.
Upvotes: 2
Views: 1248
Reputation: 31
Figured it out the stream originally started as an ifstream, and didn't use the noskipws function so once I set it there, before converting it to a stringstream everything worked.
Upvotes: 1