Originally Posted by
trenzterra
Thanks. So I guess I'll put the read line stuff inside a function...
Also, str2 does not seem to work. It outputs some funny ASCII character instead of "Notepad". Why is this so?
It must point to invalid data.
I think your whole approach is wrong. Since this is a C++ forum and not a C forum, I would assume you want a C++ solution. In that case, you should be using C++ strings, which eliminate all the problems you are having. You can then use the find() function to get the index position of the equals sign:
Code:
//open input file myInputFile, etc.
string input;
getline(myInputFile, input);
//read in a line of data from myInputFile and store it in the string input
int equals = input.find('=');
And, you can use the substr() function to divide up the string:
Code:
string program = input.substr(0,equals);
//substring from index 0 to equals--not including the char at index position equals.
string path = input.substr(equals + 1);
//substring from equals + 1 to the end of the string