Is there a way to convert strings to int and vice versa in C++? I've tried the stoi and atoi method but I get compilation error | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

Is there a way to convert strings to int and vice versa in C++? I've tried the stoi and atoi method but I get compilation error

C++ Programming

19th Jun 2019, 10:21 PM
Erick Mbugua
Erick Mbugua - avatar
2 Respuestas
+ 1
int n = 54321; string s = to_string(n); string s = "54321"; int n = stoi(s);
20th Jun 2019, 1:59 AM
Choe
Choe - avatar
19th Jun 2019, 11:59 PM
Daniel Cooper