Someone raised this code to me, that raised me to wonder what is going on there the code is as follow from VS 2019:
#include <stdio.h>
#include <string.h>
int main()
{
char y = '5';
char w = "5";
printf("size of x %x\n",&w);
printf("size of X %X\n", w);
printf("size of X in number: %d \n", w);
printf("size of Y %d\n\n", w);
w = '5';
printf("size of y %x\n", &w);
printf("size of Y %X\n", w);
printf("size of X in number: %d \n", w);
printf("size of Y %d\n\n", w);
return 0;
}
The output is as follow:
size of x 8ff8bb
size of X 30
size of X in number: 48
size of Y 48
size of y 8ff8bb
size of Y 35
size of X in number: 53
size of Y 53
What I wonder is what is really going on there? someone pointed out that ' is a char and " is a string, but if that is the case why can one put a string into a char here, and why is that the results?
Thanks for the answers I do understand this may not be really too relevant to use, but I wonder on what is going on there, I have just recently returned to relearn C
The code is compiled and gives no warnings in VS2019
Google search mostly give me results for how to put chars into an array and the like, was unable to find any info on this behavior