Examveda

What will be the output of the following C code?
#include <stdio.h>
struct p
{
    char *name;
    struct p *next;
};
struct p *ptrary[10];
int main()
{
    struct p p;
    p->name = "xyz";
    p->next = NULL;
    ptrary[0] = &p;
    printf("%s\n", p->name);
    return 0;
}

A. Compile time error

B. Segmentation fault/code crash

C. xyz

D. Undefined behaviour

Answer: Option A


This Question Belongs to C Program >> Structure And Union

Join The Discussion

Related Questions on Structure and Union