error in atoi function

this programme hass error that i dont understand :D
note: using language c not c++
# include "stdio.h"
# include "math.h"
# include "stdlib.h"
# include "string.h"

void main ()
{
char text[20],a,b;
int result=0,i;
printf (" "" WELCOME ""\r\nEnter your Expression ^_^ \r\n");
gets(text);
for( i=1;i<20;i++)
{
if (text[i]=='+')
{
a=atof(text[i+1]);
b=atof(text[i-1]);
result=a+b;
}
if (text[i]=='-')
{
}
}
printf ("result is %d\r\n",result);
}


the error is( Error 2 error C2664: 'atof' : cannot convert parameter 1 from 'char' to 'const char *')
Try;
b=atof(&text[i-1]);
text is char pointer , text[i] is char. They are different.
Last edited on
thnxx..:)
sorry but i want to ask another question how to apply the reverse polish notation concept in the c language or in this code :)
You could use Forth instead... *wince*

Or, just tweak the input to your atof statements.

i-1 and i-2 may be of interest to you.

-Albatross
Last edited on
thnxx,,:)
but if i want to evaluate (for ex.=1789563+7897854 ).. how can i apply that into the code
and thnx again for ur contact :D
Topic archived. No new replies allowed.