-
What will be the output of the following C code?
#include <stdio.h>
typedef struct NN
{
int n, m;
}s = {11, 22};
int main()
{
NN nn = s;
printf("%d\n", nn.n);
}
-
- Depends on the standard
- 11
- 22
- Garbage value
- Compilation Error
Correct Option: E
Compilation Error
main.c:5:5: error: typedef ‘s’ is initialized (use __typeof__ instead)
}s = {11, 22};
^
main.c: In function ‘main’:
main.c:8:9: error: unknown type name ‘NN’; use ‘struct’ keyword to refer to the type
NN nn = s;
^~
struct
main.c:8:17: error: expected expression before ‘s’
NN nn = s;
^
main.c:9:26: error: request for member ‘n’ in something not a structure or union
printf("%d\n", nn.n);