0

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?

canoe
  • 1,273
  • 13
  • 29

1 Answers1

2

The type of '\n' is int, therefore sizeof('\n') equals sizeof(int); on the other hand, sizeof(char) always equals 1.

Lee Duhem
  • 14,695
  • 3
  • 29
  • 47