-
What will be the output of the following C code?
#include <stdio.h>
struct
{
int n;
char m;
} stru;
int stru = 110;
int main()
{
stru.n = 110;
printf("%d %d\n", stru.n, stru);
}
-
- 110 110
- Compilation Error
- Garbage value
- Undefined behaviour
- None of these
Correct Option: B
Compilation Error
main.c:7:9: error: conflicting types for ‘stru’
int stru = 110;
^~~~
main.c:6:7: note: previous declaration of ‘stru’ was here
} stru;
^~~~
main.c: In function ‘main’:
main.c:10:13: error: request for member ‘n’ in something not a structure or union
stru.n = 110;
^
main.c:11:31: error: request for member ‘n’ in something not a structure or union
printf("%d %d\n", stru.n, stru);