What is the output and explain this code in correct way ... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the output and explain this code in correct way ...

sizeof

13th Jul 2017, 6:40 PM
Mitesh Makwana
Mitesh Makwana - avatar
5 Answers
+ 3
It's returning you the size value in BYTES.
13th Jul 2017, 7:03 PM
AgentSmith
+ 1
In pure C and with some compiler, undefined functions will be cast to type int (*)(...) so there will be no error and the size of what it is returned (which is just an integer uninitialized) is 4 as integers are 4 bytes like @Jamie said And yes, @Jamie pinpointed two biiig errors
14th Jul 2017, 12:26 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
#include<studio.h> main { int a; a=sizeof( printed("");); printf("%d",a); }
13th Jul 2017, 6:43 PM
Mitesh Makwana
Mitesh Makwana - avatar
0
why answer is 4 ?????
13th Jul 2017, 6:43 PM
Mitesh Makwana
Mitesh Makwana - avatar
0
That code won't run, compiler error... But 4 bytes is an int size (int size is *not* ever guaranteed). Memory addresses are 4 bytes IIRC on 32bit systems. Whatever code you had has been copied wrong though. I mean line 1 says "studio.h", and it degrades from there. No return or args for main? And ;); is meaningless.
13th Jul 2017, 11:38 PM
Jamie
Jamie - avatar