0

Please explain Why the answer is 4 here?

printf("%d", sizeof(printf("GeeksQuiz")));

30th Aug 2019, 9:35 PM
Suraj Patra
Suraj Patra - avatar
4 Respostas
+ 3
the printf(GeeksQuiz") return the count of chars in the string as an int, and the size of an int is 4.
30th Aug 2019, 9:44 PM
rodwynnejones
rodwynnejones - avatar
+ 2
This is memory allocation, not element size! int main() { printf("%lu", sizeof(char)); printf("%lu", sizeof(int)); printf("%lu", sizeof(float)) ; printf("%lu", sizeof(char)); } Will output: 1448 %lu is unsigned decimal (long)
30th Aug 2019, 9:45 PM
HNNX 🐿
HNNX 🐿 - avatar
0
NO! The answer would be COMPILE TIME-ERROR. Because An expression doesn’t get evaluated inside the size of operator, GeeksQuiz will not be printed. printf returns the number of characters to be printed i.e. 9 which is an integer value. sizeof operator returns sizeof(int).
13th Nov 2022, 11:35 AM
Shaik Afzal
Shaik Afzal - avatar