Thread: Using pointers to access something in a struct

  1. #1
    Registered User
    Join Date
    Nov 2005

    Using pointers to access something in a struct

    I have a struct, and I have been passed a pointer to it to the function I'm in, how do I then use this pointer to access stuff in the struct?


  2. #2
    Registered User divineleft's Avatar
    Join Date
    Jul 2006
    I'm not sure what you're saying, post some source code.

    do you mean with the "->" operator?

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Is the pointer equivalent of

    You can also do
    (*fooptr).member or fooptr[0].member if you want, though the latter is preferred if you really do have a pointer to an array of structures.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  2. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  3. Request for comments
    By Prelude in forum A Brief History of
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Replies: 2
    Last Post: 11-28-2003, 11:50 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM