Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Accessing structure members using pointers (http://www.go4expert.com/forums/accessing-structure-using-pointers-t26127/)

cindrilla 23Jun2011 18:09

Accessing structure members using pointers
 
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


All times are GMT +5.5. The time now is 04:37.