The atof function is used to convert a string to a double. Strings in C end with '\ 0' and when you do atof (stack [i]) the program does not find '\ 0', which would indicate that it is a string, and generates this error, see in the signature of the function: double atof (const char * str);
Use the strtok () function to separate your stack variable into multiple strings according to a separation pattern, the function's signature is: char * strtok (char * str, const char * delim), where char * str is the string you want separate and const char * delim is the string that has what will be used to do this separation.
Example usage:
#include <string.h>
#include <stdio.h>
int main(){
char str[80] = "Isto eh - um - teste";
char s[2] = "-";
char *token;
/* pega o primeiro token */
token = strtok(str, s);
/* caminha através de outros tokens */
while( token != NULL ){
printf( " %s\n", token );
token = strtok(NULL, s);
}
return(0);
}