0
Can anyone explain why it gives answer 6?
what will be the output of following C code? 1. struct abc 2. { 3. int b=6; 4. char c; 5. } 6. structure; 7. int main() 8. { 9. int i=sizeof(structure); 10. printf(“%d”,i); 11. }
3 Réponses
+ 3
Your code can't compile anyway, I see there initialization of field b. But, in language C, structures is only data. Initializations need call some function, like constructors, its possible by default in C++, not C.
WTF? Or I have mistake...
+ 3
It must be 5. Cause size of an integer variable is 4 and size of a char variable is 1. Sum of these variable's sizes is 5. It's contradiction!
+ 1
But its not gives 6...
https://code.sololearn.com/cAvTm96I5N1Q/?ref=app