1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Accessing structure members using pointers

Discussion in 'C' started by cindrilla, Jun 23, 2011.

?

is this question knowledge gaining?

Poll closed Jun 28, 2011.
  1. very good

    100.0%
  2. good

    0 vote(s)
    0.0%
  3. beter

    0 vote(s)
    0.0%
  4. simple

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. cindrilla

    cindrilla New Member

    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
     

Share This Page