Is there anyway to read a character from a string array into a char variable but not have the "marker position" in the input stream move?
Is there anyway to read a character from a string array into a char variable but not have the "marker position" in the input stream move?
Can you rephrase the question? You are reading from a string array into the char variable, what does an input stream have to do with it?
You can assign a character in a C++ string or C-style string to a char variable directly (using operator[] to access the character).
If you're reading from an input stream and trying to read a character without extracting it from the stream, then perhaps peek() would work?
Yes, your last line is what I am trying to do. Peek() seems like it would work but is there anyway I can use it but have it skip newlines that you know of?
Right now I am using ignore then peek but perhaps there is a cleaner way...
peek() can only peek at the next character, so if you want to peek at the character after the newline, then you'd have to ignore() it first. That shouldn't be too difficult, though, unless for some reason you wanted to leave the newline in the stream and peek at the character after it.
Perhaps you could use putback(). Extract the newline from the streem to peek the following character, and then put the newline back with putback.unless for some reason you wanted to leave the newline in the stream and peek at the character after it.
Not sure how scalable that is. Think of a blank line, and IIRC, you are only guaranteed one character of putback.