+ 3

How convert string to number?

i want look, easy example function! string a = "123"; ..... int b = a;

11th Mar 2017, 1:19 PM
Владимир Говоровский
Владимир Говоровский - avatar
4 Antworten
+ 4
use the default library/function in C++ #include <string> Readup/Google about it, there are quite a couple of functions in that. One of it has what you want.
11th Mar 2017, 1:22 PM
Wen Qin
Wen Qin - avatar
+ 2
#include <iostream> #include <stdlib.h> using namespace std; int main() { string a = "1234"; int b = atoi(a.c_str()); ++b; cout<<b<<endl; return 0; }
12th Mar 2017, 3:55 PM
Владимир Говоровский
Владимир Говоровский - avatar
+ 1
in python: b=int (a) for C++ check function to convert stoi () function is there
11th Mar 2017, 1:53 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar
- 1
int a = int(stringInAnIntegerFormat);
12th Mar 2017, 4:34 PM
Thabo Nthako