arrays as function parameters

i encounterd the following code in the c++ toutorial about data structures, but shouldnt void printmovie (movies_t movie); be void printmovie (movies_t movie[]);
since it takes an array as an arguement?



// array of structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

#define N_MOVIES 3

struct movies_t {
string title;
int year;
} films [N_MOVIES];

void printmovie (movies_t movie);

int main ()
{
string mystr;
int n;

for (n=0; n<N_MOVIES; n++)
{
cout << "Enter title: ";
getline (cin,films[n].title);
cout << "Enter year: ";
getline (cin,mystr);
stringstream(mystr) >> films[n].year;
}

cout << "\nYou have entered these movies:\n";
for (n=0; n<N_MOVIES; n++)
printmovie (films[n]);
return 0;
}

void printmovie (movies_t movie)
{
cout << movie.title;
cout << " (" << movie.year << ")\n";
}
It doesn't take an array as an argument, if you look at where printmovie is called,

 
printmovie(films[n]);


films is an array of movies_t, and it sends one element from that array, the element at n, into the printmovie function, not the whole array.
OMG, never thought of that, thx u so much dude
Topic archived. No new replies allowed.