My program has a function that reads in information until it hits a designated character, takes the text just before that character, does something with it, and then comes back for more text starting at that designated character.

So...
Special character is: 'z'
Text file: "This is a lot of text and I am only saying zune because it possess the character."

The first chunk : "This is a lot of text and I am only saying "
The second chunk: "zune because it possess the character."

My dilemma is that in order to check ahead and see the 'z', I need to first read in the z and then check its ascii number. This causes problems because the file pointer loses the 'z' and now is "une because it possess the character."

Is there any way to check ahead without losing information while reading? I'm looking for maybe a function call I overlooked or a method to do so. You do not need to present code.

Thanks

You'd be better off reading the entire line and looking through the array rather than trying to mess around with complex file reading techniques. If you can read the entire file, so much the better.

hmm..
well not diving into my project too much, I need to tell whether something is "folded" which mean I need to find in sequential order'\r''\n' and a ' ' on the next line. If the space is anything other than a space it is declared not folded and will be read later. The problem occurs when there it is not folded and the program actually takes in the first character of the next string to test for the line being folded.

I just was reading my book and came across ungetc(); might be useful.

success!
ungetc() is a lifesaver. Thanks for commenting anyways. Always helpful!

But ungetc() is non-standard and therefore not recommended. It will not work in most compilers.

Thanks for the heads up I'll ask my TA if its okay to use.

But ungetc() is non-standard and therefore not recommended. It will not work in most compilers.

Standard section 7.19.7.11 (The ungetc function) begs to differ.

Standard section 7.19.7.11 (The ungetc function) begs to differ.

Ahh, sorry. I forgot it's not related to getch() . My mistake.

But I still think it shouldn't be used.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.