View Poll Results: is this question knowledge gaining?
very good 1 100.00%
good 0 0%
beter 0 0%
simple 0 0%
Multiple Choice Poll. Voters: 1. You may not vote on this poll

Accessing structure members using pointers

Go4Expert Member
23Jun2011,18:09   #1
cindrilla's Avatar
hi friends
I know the basic rule that to access a structure member using pointer we need to use "->" operator .But as i have programmed using this i got a very unexpected output i.e the output is getting into indefinite loop
the main line which i feel might be wrong is
scanf("%s %d",&ptr->name,&ptr->prid);
where
ptr=pointer to structure variable
name & prid are product name and product id
printf("%s %d",(*ptr).name,(*ptr.prid));
though in printf i accessed it in both ways i.e one as shown above and another by using "->" operator but both dint yeild any result
thanks in advance