reading from a text file

One question...

I have a text file like:

DATA1=0;

What would be a way to look for "DATA1=" and return the value inmediately next...?

Get the line into the string, then you would have to search for the = and then either return whatever is after that, or convert it to an int/whatever and return it.
Pardon my ignorance but, while it does sound easy, I still fail to do it correctly...
closed account (S6k9GNh0)
@ firedraco: Boy was that incomplete. :/

@ Alexandro: Since I've given an example about 10 times for this very specific job, I will not show you code. However, I will mention that there are examples all over this forum concerning this and there are containers inside of the Standard Library that will help you accomplish this called the 'ifstream'. The task you need to accomplish goes like this:

Declare buffer
Read file into buffer
Interpret buffer
Free buffer (depends on your buffer)
Last edited on
Well, then perhaps you could give OP some specific string you remember from your posts so he can search for them.
I thought fd's post was succinct and complete. Just looking at the string class methods should be enough to get that far.
Topic archived. No new replies allowed.