This is a sample of code that I've written for a school science fair.
#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");
}
When I run this code I receive this error.
error C2664: 'atof' : cannot convert parameter 1 from 'char' to 'const char *'
Can anyone explain this error and give me an example on how to remedy it?