Answers for "how to convert a string to a number in c++"

8

string to int c++

// Both functions work identically though you'll need to use "#include <string>" 
atoi( str.c_str() );
stoi( str );
Posted by: Guest on April-07-2020
0

how to convert from string to int in c++

#include <iostream>
#include <sstream>

using namespace std;

int main() {
    string s = "999";

    stringstream degree(s);

    int x = 0;
    degree >> x;

    cout << "Value of x: " << x;
}
Posted by: Guest on November-20-2020

Code answers related to "how to convert a string to a number in c++"

Python Answers by Framework

Browse Popular Code Answers by Language