Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Item
    {
    int s;
    int t;
    };
    void function(struct Item*);
    int main()
    {
    struct Item I = {33, 44};
    function(&I);
    }
    void function(struct Item *ptr)
    {
    printf("%d\n", *ptr->s++);
    }
    1. 33
    2. Compilation Error
    3. 44
    4. Garbage value
    5. None of these
Correct Option: B

Compilation Error

main.c: In function ‘function’:
main.c:15:24: error: invalid type argument of unary ‘*’ (have ‘int’)
printf("%d\n", *ptr->s++);



Your comments will be displayed only after manual approval.