+ 1
int main() { printf("int: %d \n", sizeof(int)); printf("float: %d \n", sizeof(float)); printf("double: %d \n", sizeof(d
I am not understanding this the output of this . How can we say size of (char) =1byte(8bits)
6 Respostas
+ 1
What do you don't understand?
+ 1
The function sizeof get the number of bytes of one data-type. For example sizeof(char)=1 byte(8 bits)
+ 1
Print the size of integers, float and double.
The size of int is 4 bytes.
The size of float is 4 bytes.
The size of double is 8 bytes.
0
Char is 1 byte in C because it is specified so in standards.
The most probable logic is. the (binary) representation of a char (in standard character set) can fit into 1 byte. At the time of the primary development of C, the most commonly available standards were ASCII and EBCDIC which needed 7 and 8 bit encoding, respectively. So, 1 byte was sufficient to represent the whole character set.
0
Even in some non c standards a char still is 1 byte.
0
Firstly please either paste in the code in the actual post field instead of in the title because the code was cut off or provide us with a link. The sizeof operator returns the size of a type in bytes.
- The int type in C is 32 bit so 4 will be displayed (4bytes = 32bits)
- Same with the float type
- Doubles are just 64 bit floats so obviously it will be double the size (thats also where the name comes from)