C - Structures,Unions - Discussion

You Are Here :: Home > C > Structures,Unions - Discussion

 



Q.

What will be output if you will execute following code?

#include
struct address{
char *name;
char street[10];
int pin;
}ex={"G.shalini","A-1",456003},*p=&ex;
int main(){
printf("%s%s",p->name,(*p).street);
return 0;
}

A. shalini B. shalini.G
C. G.shalini A-1 D. A-1 G.shalini

Answer: Option C
Explaination:

p is pointer to structure address. -> and (*). Both are same thing. These operators are used to access data member of structure by using structure's pointer.



Discussion

Your Comments Goes here...
NameDiscussion