Hello!
How to convert string to int?
Is there any standart function for this.
atoi() doesn't work. one way is to convert string to char array and then atoi().
is there something short like
int x=str.toint();
Hello!
How to convert string to int?
Is there any standart function for this.
atoi() doesn't work. one way is to convert string to char array and then atoi().
is there something short like
int x=str.toint();
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
string str("234");
int var=atoi(str);
gives compiler error because it can handle only
char arrays;
I find that stringstream is useful.
gives compiler error because it can handle only
char arrays;If your talking about a c++ string object, don't forget about this.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
string whatever="12345678";
atoi(whatever.c_str());