Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

string to int c++

string str1 = "45";
    string str2 = "3.14159";
    string str3 = "31337 geek";
 
    int myint1 = stoi(str1); // type of explicit type casting
    int myint2 = stoi(str2); // type of explicit type casting
    int myint3 = stoi(str3); // type of explicit type casting
/* Result
45
3
31337
*/
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #string #int
ADD COMMENT
Topic
Name
4+6 =