Array Data Structures

This is a discussion on Array Data Structures within the C Programming forums, part of the General Programming Boards category; I have an array data structure struct book_type { char title [30]; float price; char authorName[30]; }; In the main ...

  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,386
    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-12-2004, 12:15 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 10:48 AM

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