converting char to int in c++

C++
int x = (int)character - 48;#include <sstream>

using namespace std;

int main()
{
    stringstream str;
    
    str << "1";

    double x;
    str >> x;
}
Source

Also in C++: