This code won't compile.
Your first line in the main function is broken: you cannot allocate an array without giving a size.
Secondly, your
getvalues
function is severly broken: You pass an array and some integer value that you modify inside the function and obviously assume that this change is visible outside the function. It is not. As a result, you pass 0 to the sorting which will not sort anything (assuming you fix the first problem above).
Your code is plain C code (beside using cin/cout), not C++ code. Use the means of C++ for your own benefit. E.g.
int getvalues(std::vector<int> &items)
{
int item = 0;
while(item >= 0)
{
std::cin >> item;
if (item >= 0) items.push_back(item);
}
return items.size();
}
int main()
{
std::vector<int> items;
if (getvalues(items)) std::sort(items.begin(), items.end());
}
Cheers
Andi