I've tested sizeof('\n')
is 4, but if when it is assigned to a char variable, then it occupies 1 byte of memory.
char enter = '\n';
sizeof(enter); // 1
What are their sizes different?
I've tested sizeof('\n')
is 4, but if when it is assigned to a char variable, then it occupies 1 byte of memory.
char enter = '\n';
sizeof(enter); // 1
What are their sizes different?
The type of '\n'
is int
, therefore sizeof('\n')
equals sizeof(int)
; on the other hand, sizeof(char)
always equals 1.