Predict the output of above program. Assume that the size of an integer is 4 bytes and size of character is 1 byte. Also assume that there is no alignment needed.
(A) Nothing is printed
(C) Garbage character followed by ‘G’
(D) Garbage character followed by ‘G’, followed by more garbage characters
(E) Compiler Error
Explanation: Since x and arr share the same memory, when we set x = 0, all characters of arr are set as 0. O is ASCII value of ‘\0’. When we do “t.arr = ‘G'”, arr becomes “\0G\0\0”. When we print a string using “%s”, the printf function starts from the first character and keeps printing till it finds a \0. Since the first character itself is \0, nothing is printed.
Quiz of this Question