#include<iostream>
#include<cstring>
usingnamespace std;
int eval(char X[],int l,int r);
int main(){
char X[10];
cout<<"Please enter an equation:";
cin>>X;
//cout<<atoi(X)+atoi(X)<<endl;
int s=strlen(X);
int l=0,r=s-1;
int box=eval(X,l,r);
cout<<box<<endl;
return 0;
}
int eval(char X[],int l,int r){
return atoi(X[l]);
}
/*why my code shows an error massage for atoi function?
Please help me. I have fallen in a trouble.*/
the error massage is error C2664: 'atoi' : cannot convert parameter 1 from 'char' to 'const char *'
No, it's not working. It shows same error massage. But it's work when I write return atoi(X). But it gives whole number of this array. But I want to show only a specific number.
suppose my array has 1,2,3. and I want to show 2 that's slot number is 1. and my executed code will show 2 not 123. If I apply this so it shows 123.