Last question for the night. I try not to post more than once per struggle haha...
This one's a bit simpler.
I have a txt file with a series of arranged numbers in the first 8 lines. Every line after is a certain phrase like "BUY ITEM" or "AWARD ITEM" followed by an integer (there are several phrases but I'm only concerned with one). Basically I'm trying to have a for or while loop where I can detect the phrase in the document, set the pointer to the end of the phrase and then fscanf the integer to the right of the phrase. The only trouble I'm having is getting the pointer to the end of the specific phrase and then reading the number. As well as the fact that the phrase is repeated on different lines and I don't want the values to be taken all at once.
I'm sure I can do a simple
while (!feof(//function for reading phrase)) {
fscanf("%d", &value);
//rest of function
And that would be that. But I've tried fseek and fget and nothing has really been able to help get the pointer to the location I need it to without having a preset location of where to go. The input file will be different each time so I can't just tell it to go 1024 spaces down or something like that. Just not sure how you would even go about this...
Also below is an example of an input file.
75 75 908
10 10
18 23.10 10.09
70 5 15
8 100 20 28.99
30 40 50 60
4 6 8 8 5 5 5 6 7 10
10
BUY ITEM 8
BUY ITEM 10
AWARD ITEM 7
BUY ITEM 1
BUY ITEM 3
AWARD ITEM 9
BUY ITEM 7
RETURN ITEM 8
Much appreciation for anyone's help.