Converting char value to int by adding 0
C++
// C++ program to convert // char to int using typecasting by adding zero #include <iostream> using namespace std; //Driver code int main() { char charvalue = 'a' ; int number = ( int (charvalue)+0); cout << number; return 0; } //this code is contributed by uomkar369 |
Output
97
C++ Program For char to int Conversion
Here we will see how to convert char to int using a C++ program. There are 6 ways to convert char to int in C++:
- Using Typecasting.
- Using static_cast.
- Using sscanf().
- Using stoi().
- Using atoi().
- Using string stream.
Let’s discuss each of these methods in detail.