Convert C chars to ASCII

To convert C language characters to ASCII code, you can use a typecasting operation to convert a character variable into an integer type. For example:

char c = 'A';
int ascii = (int)c;

printf("ASCII码为: %d", ascii);

The above code converts the character ‘A’ to its ASCII code and prints it out. It’s important to note that in C language, the character type is actually an integer type, so a character variable can be directly assigned to an integer variable for conversion.

bannerAds