Passing a pointer reference to a struct inside a struct?

This is a discussion on Passing a pointer reference to a struct inside a struct? within the C Programming forums, part of the General Programming Boards category; Is it possible to pass a struct of a struct in a function? Code: int foo (char* strArray, PriceType *prices) ...

  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    53

    Passing a pointer reference to a struct inside a struct?

    Is it possible to pass a struct of a struct in a function?

    Code:
    int foo (char* strArray, PriceType *prices) {
    ...
    }
    Code:
    validation = foo ("HelloFoo", new->prices[0]); /* new->prices is of type PriceType */

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    What is new. what is type of new->prices?
    Assuming prices is array of PriceType.
    i.e
    You need &new->prices[0]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer to union inside struct
    By lv2eof in forum C Programming
    Replies: 4
    Last Post: 05-28-2010, 06:55 PM
  2. passing struct vs. reference
    By reakinator in forum C Programming
    Replies: 4
    Last Post: 06-14-2008, 10:11 PM
  3. passing struct as reference
    By ltcabral in forum C Programming
    Replies: 7
    Last Post: 03-13-2008, 10:44 AM
  4. Problem with DMA inside a struct pointer
    By Nakor in forum C Programming
    Replies: 5
    Last Post: 09-15-2007, 08:14 PM
  5. passing struct to function by reference
    By ironfistchamp in forum C++ Programming
    Replies: 11
    Last Post: 07-03-2006, 02:05 PM

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