I am working on a project that carries out an operation between two polynomials. The polynomials are read in from a text file, which I named "functions.txt", and are in the form of "(2*x^2+5*x^4-3*x)+(6*x+2*x^3+x^5)". There are an unknown amount of these equations and the operation can be '-', '+' or ''. I have managed to read in the file and store each character into a character array. At this point, I am simply having trouble trying to find the math operator ('', '-', or '+'). I figured find the ')' in the string and take the character immediately after it and store it into the mathOperator; if the character after ')' is not '\0'. However, this does not seem to work as it returns " ". Any suggestions and help are greatly appreciated. Here is where the problem is:
if(polyFile.good())
{
while(!polyFile.eof() && counter < MAX_SIZE)
{
polyFile.get(polyArray[counter]);
++counter;
}
polyArray[counter - 1] = '\0';
for(int i = 0; i < polyFile.eof(); ++i)
{
if(polyArray[i] = ')')
{
polyArray[i + 1] = mathOperator;
cout << mathOperator;
}
}
}
else
{
cout << "The file could not be opened." << endl;
}