I need to open a text file as input, extract some data from it, saving it to another file.
I'm reading through the source file line by line using something along the lines of:
while (!spoolfile.eof()) {
spoolfile.getline(buff, sizeof(buff));
However, I'm not sure how to extract the data I need.
For example, one line in the file line might look like:
A Order : 1234 B
If I need to extract the '1234' what's the best way to go about it? I'd appreciate two ways of doing it:
i) Assuming the text I need to extract always occurs at the same position in the line (eg at character position 25 for 4 characters)
ii) If the position and length of the text to be extracted could vary. I think I'd need to look for the ':' and then move two spaces to the right, then extract any following chracters until a space occurs.
Sorry, I know it's very basic, but I've just realised it's been 10 years since I last did any serious C/C++ programming, and even then I was bodging things as I went along!
Thanks very much.
I'm reading through the source file line by line using something along the lines of:
while (!spoolfile.eof()) {
spoolfile.getline(buff, sizeof(buff));
However, I'm not sure how to extract the data I need.
For example, one line in the file line might look like:
A Order : 1234 B
If I need to extract the '1234' what's the best way to go about it? I'd appreciate two ways of doing it:
i) Assuming the text I need to extract always occurs at the same position in the line (eg at character position 25 for 4 characters)
ii) If the position and length of the text to be extracted could vary. I think I'd need to look for the ':' and then move two spaces to the right, then extract any following chracters until a space occurs.
Sorry, I know it's very basic, but I've just realised it's been 10 years since I last did any serious C/C++ programming, and even then I was bodging things as I went along!
Thanks very much.