Skip to content

Instantly share code, notes, and snippets.

@mwiegant
Last active October 12, 2015 21:07
Show Gist options
  • Save mwiegant/4958b633e47e5048490f to your computer and use it in GitHub Desktop.
Save mwiegant/4958b633e47e5048490f to your computer and use it in GitHub Desktop.
C++, How to convert a number from Char to Int
#include <iostream>
using namespace;
int main()
{
char charSix = '6';
// int intSix = int( charSix ) - 48; // DON'T DO THIS, Leverington calls this 'terrible code'
int intSix = int( charSix - '0');
cout << "The value of intSix is: " << intSix << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment