I know this might seem like a repeat of an already existent thread, however give me a moment to explain...
What I have so far is a function that reads in a script file and stores each word in an array of custom objects.
function:
void fileTester::readFile( string tempName )
{
fileName.append( tempName );
inFile.open( fileName.c_str() );
string tempChar;
int tempx = 0;
if( !inFile )
{
cout << "There was an error opening the script file\n";
cout << inFile;
}
else
{
cout << "File found!\n";
}
while( inFile.peek() != EOF )
{
inFile >> tokens[ tempx ].tokenString;
tempx++;
}
codeLength = tempx;
}
object:
typedef struct
{
string tokenString;
int tokenID;
int lineNumber;
} tokenStruct;
tokenStruct tokens[ 5000 ];
The problem at hand is that I cant find a way to keep the functionality of the entire program while at the same time finding and storing the relevant line number the string was located at on the file in the token objects. The solutions I have tried thus far have resulted in either breaking the words up into bits that the rest of my program cant understand or dropping characters altogether. If you know of a simple alteration that doesn't interfere with the functionality of the rest of my program I would greatly appreciate it.