this little program describes my problem which I have in bigger project:
int main()
{
string str1="11111111";
string str2="22222222";
char a=str1[2];
char *a1=&a;
int var1= atoi(a1);
char b=str2[2];
char *b1=&b;
int var2= atoi(b1);
cout<<var1<<endl;
cout<<var2;
return 0;
}
Why I'm getting
1
21
istead of
1
2
?
Is there any way to fix this? - thanks for the help I trying to figureout for two hours