November 6th, 2012, 10:54 PM
Sizeof data types
I am getting output for below code as 8 4 4 in gcc version 4.5.2. Can anyone explain why I am getting this output ?
November 6th, 2012, 11:48 PM
Because on your system, a floating point number is 8 bytes, an integer is 4 bytes, and a character is 4 bytes.
November 7th, 2012, 12:24 AM
How can integer and char can take same byte size ?
Originally Posted by E-Oreo
I guess I found the answer. In sizeof('A'), 'A' is replaced by 65 and sizeof(65) which is integer and that's how it shows 4. Not very sure though.
November 7th, 2012, 01:28 AM
In C, character constants are integers, but in C++, character constants are chars.
If you compiled this as a C++ program, you would most likely see 8 4 1 as the output.
November 7th, 2012, 04:31 AM
Originally Posted by salem
November 7th, 2012, 01:57 PM
size of a double
sizeof an int
sizeof a character constant
In C a character constant in an int not a char.
November 8th, 2012, 03:27 AM
you can get value of int but not get value of character.
November 8th, 2012, 02:37 PM
What does that mean? A character constant is an int, and a char is an integer type so also has a "value".
Originally Posted by miteshaegis