Hello,
I simply need to allocate an array with a value given to me from command line. So from main there is a function to call the method:
allocate_array(grades, numgrades);
The declaration of these variables are:
double *grades;
size_t numgrades;
Inside of my allocate_array function, I ask for the size of array and save it in the variable numgrades. Then create grades of size numgrades. When I try and access these variables in another function I cannot. The next function call is:
read_input(grades, numgrades);
I can read input and output it fine inside of allocate_array, but not outside of it. any ideas of where the problem is?
allocate_array looks like this:
void allocate_array(double *grades, size_t numgrades) {
cout << endl << "Enter the size of the array to be allocated: ";
cin >> numgrades;
grades = new double(numgrades);
}// allocate_array...
I simply need to allocate an array with a value given to me from command line. So from main there is a function to call the method:
allocate_array(grades, numgrades);
The declaration of these variables are:
double *grades;
size_t numgrades;
Inside of my allocate_array function, I ask for the size of array and save it in the variable numgrades. Then create grades of size numgrades. When I try and access these variables in another function I cannot. The next function call is:
read_input(grades, numgrades);
I can read input and output it fine inside of allocate_array, but not outside of it. any ideas of where the problem is?
allocate_array looks like this:
void allocate_array(double *grades, size_t numgrades) {
cout << endl << "Enter the size of the array to be allocated: ";
cin >> numgrades;
grades = new double(numgrades);
}// allocate_array...