-
What will be the output of the following C code?
#include <stdio.h>
struct student
{
char *name;
};
void main()
{
struct student s1[2], s2[2];
s1[1] = s1[0] = "Ajit Kumar Gupta";
printf("%s %s", s1[0].name, s1[1].name);
}
-
- Compilation Error
- Garbage value
- Ajit Kumar Gupta
- Undefined behaviour
- None of these
Correct Option: A
Compilation Error
main.c: In function ‘main’:
main.c:9:23: error: incompatible types when assigning to type ‘struct student’ from type ‘char *’
s1[1] = s1[0] = "Ajit Kumar Gupta";