Last active
October 12, 2015 21:07
-
-
Save mwiegant/4958b633e47e5048490f to your computer and use it in GitHub Desktop.
C++, How to convert a number from Char to Int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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