How do I read from a file till a particular character is reached and then seek to the next character and continue reading in C++.
In my program I am using some HTML syntax and generating a .htm file… So in my C++ code I have added the tags.
But when I read from my .htm file I want it to not include the tags.
What I plan on doing is reading the file till '<' is encountered then just seek to the point till '>' is encountered and continue reading from there.
First of all, you should be aware that doing this correctly is quite a bit trickier than you apparently think.
Just answering the question as you asked it, you can use
istream::getto read a character at a time until you get a ‘<‘. You can useignoreto ignore characters up to the next ‘>’ in the stream.Getting back to the first point, however, that generally won’t work correctly. In particular, it’s entirely possible for a tag to contain a string, and the string (in turn) contain a ‘>’ that is not the close of the tag. As such, to have any hope of parsing the HTML correctly, you need to parse for strings inside the tags, and when you find them, skip across their contents rather than treating any ‘>’ they might contain as ending the tag.