having trouble with function using array as formal parameter

Before i begin with my problem anyone who is just going to post a link to the array or functions beginners section please do not reply in this post

I am trying to get a function to work that take array as a parameter (the array is an array of objects)

each object contains (name,title,year etc)

In my function in trying to compare each year of each element in the array and return the oldest year



here is some of my code


this is the function call:

ageOfBook(bookList[].getBookYear());

i was also trying this

ageOfBook(bookList[]);

this is the function body

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int ageOfBook(book bookList[])
{
    
    int oldestBook=bookList[0].getBookYear();
    
    
    
       for (int i=0; i<13; i++) 
       {

           if (bookList[i].getBookYear()<oldestBook) 
           {
              oldestBook=bookList[i].getBookYear();
           }
        }
        return oldestBook;      
}


also, the .getBookYear function is part of a class.

Any help will be greatly appreciated
Try with int ageOfBook(book * bookList)
thanks for the reply, what is the purpose of the asterix symbol in that context what will that do in the program?
Simple. Now booklist, in that function, is a book pointer.
An array is like a pointer with many values, just letting you know.
Eventually, this website has a lot of infos on pointers: http://www.google.it :'D
Topic archived. No new replies allowed.