Thread: Basic pointers to structures question...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    13

    Basic pointers to structures question...

    header:
    Code:
    struct termlist
    {
          uint32_t num_terms; 
          char **term;           
    };
    
    int getMetaData( uint32_t specific_tag, termlist **terms);
    main:
    Code:
    int main(int argc, char **argv)
    {
    
    uint32_t specificTag;
    specificTag = atoi(argv[1]);
    
    termlist *sample1;
    
    getMetaData( specificTag, sample1 );
    
    ...
    
    }

    Hi, I'm really confused about pointers to structures. I'm trying to understand this snippet of code above.

    The function prototype requires a double pointer to the structure, termlist **terms. But in main when calling the function only a pointer to the structure is passed, sample1.

    I'm quite confused on how the function prototype requires a double pointer, but in main only a single pointer is passed.


    Thanks!
    Last edited by superbbrr; 05-16-2012 at 11:57 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers basic question
    By sed_y in forum C Programming
    Replies: 9
    Last Post: 06-23-2011, 01:47 PM
  2. Basic question about declaring variables/structures
    By bnyec in forum C Programming
    Replies: 11
    Last Post: 05-19-2011, 07:49 PM
  3. Pointers and Data Structures (Simple Question, I think)
    By Flamefury in forum C Programming
    Replies: 16
    Last Post: 11-23-2009, 12:17 AM
  4. Structures and pointers question
    By cjohnman in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 01:48 PM
  5. Pointers to structures - Beginner question
    By RobJ in forum C Programming
    Replies: 6
    Last Post: 04-10-2006, 05:57 PM