I think ye' problems start here:
while (str !='\n' && thearray!="model=")
//set all values of thearray to bigarray until its end of line or "model="
{
thearray[i] = bigarray[i];
i++;
}
If you were using <string> class objects, you would able to make the != comparison. However, the only way you could make a boolean comparison between a cstring
thearray and a string literal
"model=" would be to:
1. First, make sure that in your text file, "model=" is followed immediately by a null terminating character '\0' (using escape characters in your .txt file works best when your file is opened in binary mode)
2. Using the <cstring> function
strcmp( ), you can make a direct comparison between two character arrays. The function will return 0 if there are no differences between the cstrings.
Example, lets say you called openfile.getline(bigarray,300); Assuming that the first line of the .txt file contains the "model=" string token you are looking for, bigarray would then look like this:
[m][o][d][e][l][=][\0][4][9][5][2]
Notice that the delimiting '\n' newline character has been discarded by use of the getline( ) function. Tip: you will probably want the '\n' newline character in this case in order to determine the end of your array. Either add back in the '\n' character yourself, or use
get( ) instead of getline( ).
With the null-terminated "model=", we can now pass bigarray into the strcmp( ) function, and it will only access the cstring up until it hits a null termiator. Even though bigarray has a whole bunch of stuff in it, strcmp(bigarray, "model=") would still return 0 indicating that the cstrings are equal.
At this point, you have determined that the line you extracted from your text file is what you are looking for. You can now make the assumption that everything starting at bigarray[7] will contain the numbers.