how to convert char to int in c++

#include <iostream>
using namespace std;

int main() {
    char charValue = '7'; // Step 1: Declare a char variable and assign a character value to it
    int intValue;

    intValue = charValue - '0'; // Step 2: Subtract the ASCII value of '0' to convert char to int

    cout << "Converted int value: " << intValue << endl; // Step 3: Display the converted int value

    return 0;
}