1.

What will be the output of the following C code?
#include <stdio.h>
struct p
{
int x;
char y;
};
void foo(struct p* );
int main()
{
typedef struct p* q;
struct p p1[] = {15, 52, 43, 34, 25, 16};
foo(p1);
}
void foo(struct p* p1)
{
q ptr1 = p1;
printf("%d n", ptr1->x);
}

A. Undefined behaviour
B. 15
C. Compilation Error
D. Segmentation fault
E. None of these
Answer» D. Segmentation fault


Discussion

No Comment Found

Related MCQs