0
How to use stoi?
I want to use a switch statement in C++ to check for user input, however, the input I want the switch to check is a string. I've read that by converting strings into integers (e.g. by using stoi) it is possible to use a switch statement to perform this task. Can someone show me an example of a conversion string -> integer done with stoi?
2 ответов
+ 3
u can use atoi and its the same, string to int
string x = "10"
int number = atoi(x.c_str())
+ 1
@n3twork
which header file should i be including for atoi function.
[edit] i got it. btw thanks for your answer.