Thread: Array Data Structures

  1. #1
    Unregistered
    Guest

    Array Data Structures

    I have an array data structure struct book_type {
    char title [30];
    float price;
    char authorName[30];
    };

    In the main program, I am trying to define an array of structures of the book_type (maximum 100 books) and pass the array of structures in the function, having the following prototype:

    int readData( struct book_type [ ], int );

    I have been working on this for the past day and a half and can not figure it out ... i really need help on this one

    ThanX

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    How do you pass the array to the function?

    I think it should be done in a way like:

    struct book_type book_types [ARRAY_SIZE];

    readData (&book_types[0], data);

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I think it should be done in a way like:

    struct book_type book_types [ARRAY_SIZE];

    readData (&book_types[0], data);
    No. Try this:

    readData( book_types, myValue );

    If you're passing an array, you don't need to bother specifying the address of its first element. Just use the array name.

    If you're passing a pointer to the array, that's different. But if you're just passing an array, just use its name.

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 12-05-2008, 02:18 AM
  2. Replies: 19
    Last Post: 12-17-2007, 02:57 AM
  3. Template Array Class
    By hpy_gilmore8 in forum C++ Programming
    Replies: 15
    Last Post: 04-11-2004, 11:15 PM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM