Coventing string to int/int to string

If i have a string "123" how can I convert it to the int 123
also, how can I do it from int to string?
You can use std::to_string(int) to turn a number into a string.
You can use std::atoi(string.c_str()) to turn a string into an integer.
I tried aoit
But an error comes out
error: cannot convert 'std::basic_string<char>' to 'const char*' for argument '1' to 'int atoi(const char*)'|

my code is
cout << atoi(zip[0]);
where zip[0] is a vector of string.
You need to access the const char * string that lies inside by doing:

std::cout << std::atoi(zip[0].c_str());
Finally works, thank you for all of you
Topic archived. No new replies allowed.