So im still pretty new to C++ and have been doing a program for a while now. I think I am slowly getting it but keep getting an error "Intellisense: operand of '*' must be a pointer." on line 36 column 10. What do I need to do to fix this error? Im going to get to the other functions as i finish each one so sorry for the extra function declaration
// This program will take input from the user and calculate the
// average, median, and mode of the number of movies students see in a month.
#include <iostream>
using namespace std;
// Function prototypes
double median(int *, int);
int mode(int *, int);
int *makeArray(int);
void getMovieData(int *, int);
void selectionSort(int[], int);
double average(int *, int);
// variables
int surveyed;
int main()
{
cout << "This program will give the average, median, and mode of the number of movies students see in a month" << endl;
cout << "How many students were surveyed?" << endl;
cin >> surveyed;
int *array = new int[surveyed];
for (int i = 0; i < surveyed; ++i)
{
cout << "How many movies did student " << i + 1 << " see?" << endl;
cin >> array[i];
}
median(*array[surveyed], surveyed);
}
double median(int *array[], int num)
{
if (num % 2 != 0)
{
int temp = ((num + 1) / 2) - 1;
cout << "The median of the number of movies seen by the students is " << array[temp] << endl;
}
else
{
cout << "The median of the number of movies seen by the students is " << array[(num / 2) - 1] << " and " << array[num / 2] << endl;
}
}
arrayis an array ofint. On line 36 you do*array[surveyed]. This accesses the array array (bad naming here) at index surveyed. This gives an int which then the * tries to de-reference. An int is a primitive type, which isn't a pointer so can't be de-referenced.*array[surveyed]toarray.So im still pretty new to C++ and have been doing a program for a while nowSo you're saying that you couldn't find one of the literally hundreds of thousands of examples showing you the proper way to pass an array and how to declare the function properly?