I have been struggling with this for the past couple of days, could someone PLEASE help?
I need to read in a file (I have no problems doing this), however while there are certain numbers I have to bring in and store into a variable: ( I have attached a sample data file and my program is below along with where I am confused)...
so when the file is being read in it need to look for 3 things, including "/Scan Size: " , when it sees it, it needs to be able to read the number that has been assigned to it and store it in a variable. So in the sample data file, when it sees "\Scan Size: " it needs to read in 2678.88, and the other 2 are the "\Z sensitivity: " and "\Z max: "
also, my compiler(codewarrior) does not allow for a direct delaration of strings, instead as an array of characters....
I have my program below and have attached my data file...
I really will appreciate any help any one can give...thanks in advance
char buffer1 ;
//this compiler, codewarrior, does not allow string declarations,
//they have to be declared as an array of characters
//these are the 3 things to be looking for
char Scansize = "\Scan Size: ";
char Zsen = "\Z sensitivity: ";
char Zmax = "\Z max: ";
while(!infile.eof()) //need to read till reaches EOF
c = infile.get();
if (strncmp (c, "\Scan Size: ", 12)==0); //??not sure how to use strncmp here, because it is an array of chars not a string??
//??not sure how to bring in the number assigned to it
} } }
thanks for any help...