I'm trying to show the number the first user inputted in ascending and descending order. The first part works great, the descending part gives me Invalid Null Pointer
Sorting Functions
bool ascending (int i, int j) {return i < j;}
bool descending (int i, int j) {return i > j;}
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
cout << "Your four digit number in ascending order: ";
sort(fourDigitNumber.begin(), fourDigitNumber.end(), ascending);
string inputInAscending;
for(int i = 0; i != fourDigitNumber.size(); i++)
{
cout << fourDigitNumber[i] << " ";
inputInAscending += fourDigitNumber[i];
}
cout << " \nYour four digit number in descending order: ";
sort(fourDigitNumber.begin(), fourDigitNumber.end(), descending);
string inputInDescending = 0;
for(int a = 0; a != fourDigitNumber.size(); a++)
{
cout << a;
cout << fourDigitNumber[a] << " ";
inputInDescending += fourDigitNumber[a];
}