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

    Joined:
    Sep 26, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    hyderabad
    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

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice