Home » C Programming » Functions » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct M
    {
    char *name;
    struct M *next;
    };
    struct M *ptrary[10];
    int main()
    {
    struct M m1, m2;
    m1.name = "xyz";
    m1.next = NULL;
    ptrary[0] = &m1;
    strcpy(m2.name, m1.name);
    ptrary[1] = &m1;
    printf("%s\n", ptrary[1]->name);
    return 0;
    }
    1. Compilation Error
    2. Garbage value
    3. Prayag
    4. Segmentation fault
    5. None of these
Correct Option: D

Segmentation fault



Your comments will be displayed only after manual approval.