Hi,
I'm quite new to C++ and I'm trying to figure out how to do something, I hope someone can help. Basically, I have a text file which I want my program to open. This has a number of data entries in it but I'm only concerned with a couple.
A few lines start with 'EXP_SHOT_MAP' and I want to seek as far as the first occurance of this string. I then want to seek along that line to '('. There's loads of ('s so I need to go to EXP_SHOT_MAP first. I then want to store the first character after '('. Presumably using getchar().
How would i do this?
Im not gonna write out the code for you, but some functions from c that you may want to look at are fopen, fclose, fgets, sscanf, strncmp.
fopen opens a file and assigns it to a file pointer (FILE *) , this can then be used by other functions. fclose is just used to clean up open files, you pass it an open FILE * and it will close it for you.
fgets will retrieve the actualy lines from your file and store them into variables (char *), you can then use sscanf to parse those lines and retrieve certain values. strncmp can then be used to check those values that you pulled out of those lines.
both of these functions are part of stdio.h, and im sure there are c++ equivalent functions out there, but this is at least a start.
Hope that helps!