#include<iostream>
#include<memory>
#include<fstream>
usingnamespace std;
void sortArray(int *, int);
int main()
{
int student;
cout<<"How many students do you wish to analyse?"<<endl;
cin>>student;
unique_ptr<int[]> scores(newint[student]{});
unique_ptr<int[]> num(newint[student]{});
ifstream in;
in.open("scores.txt");
for(int x=0; x<student; x++)
{
in>>scores[x]>>num[x];
}
in.close();
sortArray(scores, student);
cout<<scores[0];
}
void sortArray(int *pointer, int size)
{
cout<<"I am in!";
//Haven't started coding this part yet
}
The sort function expects a raw pointer (this is correct, the function does not own the array object).
Retrieve the underlying raw pointer with std::unique_ptr::get() and pass that to the function. http://en.cppreference.com/w/cpp/memory/unique_ptr/get