Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct furniture
    {
    int a;
    int b;
    };
    void fun(struct furniture*);
    int main()
    {
    struct furniture frn1 = {12, 22};
    fun(&frn1);
    }
    void fun(struct point *ptr)
    {
    printf("%d\n", *ptr.a++);
    }
    1. Compilation Error
    2. 12
    3. Segmentation fault/code crash
    4. 22
    5. None of these
Correct Option: A

Compilation Error

main.c:13:21: warning: ‘struct point’ declared inside parameter list will not be visible outside of this definition or declaration
void fun(struct point *ptr)
^~~~~
main.c:13:10: error: conflicting types for ‘fun’
void fun(struct point *ptr)
^~~
main.c:7:10: note: previous declaration of ‘fun’ was here
void fun(struct furniture*);
^~~
main.c: In function ‘fun’:
main.c:15:28: error: ‘ptr’ is a pointer; did you mean to use ‘->’?
printf("%d\n", *ptr.a++);
^



Your comments will be displayed only after manual approval.