"Space" or "any single character" actually has an integer type equal to the ASCII value of that character. Thus, the size will be 4 bytes. If you create a symbol variable and store a symbol in it, then only it is stored in 1 byte memory.
char ch; ch=' '; printf("%d",sizeof(ch));
For everything to be a string, it must be terminated with a null character, represented as "\ 0". If we write the string "hello", it is actually stored as 'h' 'e' 'l' 'l' 'o' '\0' , so that the system knows that the line ends after "o" in "hello" and stops read when a null character arrives. The length of this string is still 5 if you use the strlen () function, but actually sizeof (string) is 6 bytes. When we create an empty string, for example, "", the length is 0 and the size is 1 byte, since it should end where it starts, that is, at the 0th character. Therefore, an empty string consists of only one character, which is a null character, specifying a size of 1 byte.
source share