Casting Char to Int in C

C Program to cast char to int

Source code :

#include <stdio.h>


int main(){
    
    char c = '1';
    int i = c - '0';
    
    printf("%d\n",i);
    printf("Size of i is %ld",sizeof(i));

    return 0;

}

Output :

1
Size of i is 4

Notes :

The size of i will be 4 since it was casted to int.


Output :


                

Comments :