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!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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 Réponses
+ 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