Here's some ideas to get you going. This is not complete code (and I left out the EOF error checking that will be needed in your final application).
Code:
int operand1 = 0, operand2 = 0;
while (EOF != (c = fgetc(fp)))
{
if(isdigit(c))
{
/* This is a digit, and therefore is part of operand1 */
}
}
c = fgetc(fp);
if(c == '+')
{
/* This is an addition operation */
}
else if(c == '-')
{
/* This is subtraction */
}
else
{
/* Error, we expected + or - */
}
while (EOF != (c = fgetc(fp)))
{
if(isdigit(c))
{
/* This is a digit, and therefore is part of operand2 */
}
}
There are better ways of solving your problem than the code up above, but I wanted to keep it simple.