Character type data is stored internally in C or C by its ASCII value. If we want to print a single character as an integer, we will get the ASCII value. However, when we try to print multiple characters using single quotes, it prints some weird output.
Please check the following program to get the idea.
#include <stdio.h> int main() { printf("%d</p><p>", 'A'); printf("%d</p><p>", 'AA'); printf("%d</p><p>", 'ABC'); }
65 16705 4276803
The ASCII of A is 65. So initially it shows 65 (01000001). Now for AA it shows 16705. This is 6565 (01000001 01000001) = 16705 in ASCII. For the third one, the value is ABC (01000001 01000010 01000011) = 4276803.
The above is the detailed content of In C language, assign multiple characters to an int variable. For more information, please follow other related articles on the PHP Chinese website!