这是我为学校科学博览会编写的代码示例。
#include <iostream>
#include <math.h>
using namespace std;
struct FUNC{
char token;
FUNC *left;
FUNC *right;
};
double eval (FUNC *head){
if (head->left==NULL){
return atof(head->token); //this is where the error occurs
}
}
void main(){
FUNC node1= {'1',NULL,NULL};
cout << eval(&node1)<< endl;
system("pause");
}
当我运行此代码时,我收到此错误。
error C2664: 'atof' : cannot convert parameter 1 from 'char' to 'const char *'
谁能解释这个错误并给我一个如何补救的例子?