c++ - Reading from ifstream won't read whitespace -


i'm implementing custom lexer in c++ , when attempting read in whitespace, ifstream won't read out. i'm reading character character using >>, , whitespace gone. there way make ifstream keep whitespace , read out me? know when reading whole strings, read stop @ whitespace, hoping reading character character, avoid behaviour.

attempted: .get(), recommended many answers, has same effect std::noskipws, is, spaces now, not new-line character need lex constructs.

here's offending code (extended comments truncated)

while(input >> current) {     always_next_struct val = always_next_struct(next);     if (current == l' ' || current == l'\n' || current == l'\t' || current == l'\r') {         continue;     }     if (current == l'/') {         input >> current;         if (current == l'/') {             // explicitly empty while loop             while(input.get(current) && current != l'\n');             continue;         } 

i'm breaking on while line , looking @ every value of current comes in, , \r or \n not among them- input skips next line in input file.

there manipulator disable whitespace skipping behavior:

stream >> std::noskipws; 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -