Home » C Programming » Pointers » Question
  1. What is the output of this C code?
    #include <stdio.h>
    int main()
    {
    char *p[1] = {"Interview Mania"};
    printf("%s", (p)[0]);
    return 0;
    }
    1. Compile time error
    2. Undefined behavior
    3. Interview Mania
    4. None of the mentioned
Correct Option: C

The output will be “Interview Mania”. Here is why:

{"Interview Mania"} denotes an array of strings and char *p [1] is declaring an array to hold 1 character pointer. The assignment operator will make the first character pointer point to "Interview Mania".



Your comments will be displayed only after manual approval.