What will be the output of the following C code? [code] #include <stdio.h> struct p { struct p *next; int

What will be the output of the following C code?
Code:
     #include <stdio.h>
    struct p
    {
        struct p *next;
        int x;
    };
    int main()
    {
        struct p* p1 = malloc(sizeof(struct p));
        p1->x = 1;
        p1->next = malloc(sizeof(struct p));
        printf("%d\n", p1->next->x);
        return 0;
    }
A. Compile time error
B. 1
C. Somegarbage value
D. 0
 

Tìm kiếm

Back
Top