struct pointer to function syntax

This is a discussion on struct pointer to function syntax within the C Programming forums, part of the General Programming Boards category; here is my code: Code: int main(void) { struct money { char category[30]; char month[5]; int day; char purchase_description[30]; float ...

  1. #1
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528

    struct pointer to function syntax

    here is my code:

    Code:
    int main(void)
    {
        struct money {
    	char category[30];
    	char month[5];
    	int day;
    	char purchase_description[30];
    	float purchase[30];
        };
    
        struct money money_log[MAX];
        struct money *p_money_log;  
        p_money_log = &money_log[0];
    What I want to do is have the pointer to the structure passed to different functions, however I have not been able to find a suitable example of the syntax for the function call. Do I have to use the keyword struct in the argument list? Or can I just do something like:

    Code:
     
    void some_func(*p_money_log)
    {
    .......
    }
    I actually know this is incorrect - as there is no data type in the parameter list. Suggestions on how to pass the pointer are welcome. Thanks.

    ~/

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    void function( struct mystruct *myptr );
    Is that what you're trying to do?

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    85
    Code:
    void some_func(struct money *p_money_log)
    {
         ...
    }
    
    /* pointer to the pointer */
    void another_func(struct money **pp_money_log)
    {
         ...
    }
    
    int main(void)
    {
         struct money *p_money_log;
    
         some_func(p_money_log);
         another_func(&p_money_log);
         ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-13-2011, 09:28 AM
  2. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  3. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 03:49 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21