heres more on the code.
sorry if i cant put it all...
Code:
fgets(line, 80, fr);
while(fgets(line, 80, fr) != NULL)
{
p = strtok(line," ");
while (p != NULL)
{
n = n++;
some code here....
else
{
if(*p == 'U')
{
m = U;
}
else if(*p == 'P')
{
m = P;
}
else
{
m = atoi(p);
}
if(op == '+')
{
ans = ans + m;
}
else if(op == '-')
{
ans = ans - m;
}
else if(op == '*')
{
ans = ans * m;
}
else if(op == '/')
{
ans = ans / m;
}
else if(op == '%')
{
ans = ans % m;
}
else if(op == '^')
{
ans = ans ^ m;
}
}
}
i tried putting if
Code:
( strcmp("abs",op)==0)
{
if ( m >= 0)
return m;
else
return -m;
}
above the addition code but it wouldnt work...
this calculator uses fprintf and fscanf...~_~
another thing how do i get the exponent to work?
it doesnt seem to work...~_~