usage of 2 charectors in single qoutes in c
- by user1632141
#include<stdio.h>
int main()
{
char ch = 'A';
printf("%d\n",'ag');
printf("%d\n",'a');
printf("%d, %d, %d, %d", sizeof(ch), sizeof('a'), sizeof('Ag'), sizeof(3.14f));
return 0;
}
I used to have many doubts on the output of this question while running on g++ and gcc.
But I have cleared almost all the doubts by referring these links:
Single and double quotes in C/C++
Single quotes vs. double quotes in C
I still need to understand one thing about the output of this question.
Can someone please explain the output of printf("%d\n",'ag'); mentioned above in the program. How is it actually stored in the memory?
The output for the program on the Linux/GCC platform is:
24935
97
1, 4, 4, 4