/*splits string by every ' ' char and makes it a vector
sorts the vector and returns a pointer to sorted vector*/
std::vector<int> *splitAndSort(std::string nums)
{
std::vector<int> newNums;
std::vector<int> sortedNums;
std::string number = "";
for(int i = 0; 0 < nums.length(); i++)
{
//splitting algorithm
if(nums[i] == ' ')
{
newNums.push_back(std::stoi(number));
number = "";
}
else
{
number = number + nums[i];
}
}
int highest = 0;
while(newNums.size() != sortedNums.size())
{
for(int i = 0; i < newNums.size(); i++)
{
if(newNums[i] > highest)
{
highest = newNums[i];
sortedNums.emplace_back(highest);
}
}
}
return &sortedNums;
}
So i know that you need to return arrays with a pointer, but i didn't know if you need to return vectors with a pointer so I used a pointer, is that not what I should do?