This code is supposed to sort the numbers I input. I get only 0's
// Group Project 10.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
void selectionSort (vector< int> list, int length);
void fillArray(vector< int> list, int length);
int main ()
{
int length;
vector< int> list(4);
length = list.size ();
cout << "Enter 4 integers: "; //Prompt user to input 10 digits
fillArray(list, length); //Function that fills the array with the digits from the console
cout << endl;
// selectionSort (list, length);
unsigned int index;
for (index = 0; index < length; index++)
{
cout << list[index];
}
}
selectionSort (vector<int> list, int length)
{
int index;
int smallestIndex;
int minIndex;
int temp;
for (index = 0; index < length -1; index ++)
{
smallestIndex = index;
for (minIndex = index +1; minIndex < length; minIndex++)
{
if (list[minIndex] < list[smallestIndex])
{
smallestIndex = minIndex;
}
temp = list[smallestIndex];
list[smallestIndex] = list[index];
list[index] = temp;
}
}
}
//Function to fill up the array
void fillArray(vector< int> list, int length)
{
int i;
for (i = 0; i < length; i++)
{
cin >> list[i];
}
}