+ 1
PROBLEM OF CONVERTING STRING TO INTEGER
I could be wrong, but shouldn't it print the same result as it is in string? What is the problem and how should I solve It? https://code.sololearn.com/cU6jE8t644ip/?ref=app
6 Réponses
+ 2
Try using function stol. It converts a string to a long integer.
std::cout << std::stol(code) ;
Edit : you can do, if you want :
std::cout << atol(code.c_str())
+ 2
The value you given is not in range of intiger.
Because of overflow, you are getting converted value..
+ 2
Yes. Use stol(code) ;
I just seen now..
+ 1
Théophile Thanks for help :)
0
Jayakrishna maybe you know how to solve the problem?