lllook
lllook

Reputation: 749

unwanted skipping of whitespaces

I am using this to read input:

istringstream iss;
string typ, data;
char c1, c2;
iss >> skipws >> c1 >> typ >> noskipws >> c2 >> data;

input line can look like this " #text Markup used in this document is compatible with " without quotes

what I want to achieve is that after my code variable data will contain "Markup used in this document is compatible with "

but instead this code ignores everything after word Markup even after I specified that I dont want it to skip whitespaces with noskipws

Upvotes: 0

Views: 47

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409176

If you read e.g. this std::noskipws reference you will see that it

[...] disables skipping of leading whitespace by the formatted input functions

It doesn't really skip intermingled whitespace in input, reading into a string always stops on whitespace.

Instead you could use std::getline to get the remainder of the line.

Upvotes: 3

Related Questions