Can some one please tell me why I'm getting a 'Segmentation fault' on this code?
Code:
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int radixSort(vector<long> &, int);
int main(){
vector<long> to_Sort;
long int_Read = 0;
while(cin >> int_Read){
cin >> int_Read;
to_Sort.insert(to_Sort.begin(), int_Read);
}
cout << to_Sort.size() << " ";
radixSort( to_Sort, to_Sort.size() );
cout << to_Sort[0] << endl;
return 0;
}
int radixSort( vector<long> & to_Sort, int list_Size ){
int i, j, k, cur_Factor;
const int max_Digits = 10;
queue<long> pass_Qu[max_Digits];
for( i = 0, cur_Factor = 1; i < max_Digits; cur_Factor *= max_Digits, i++ ){
for( j = 0; j < list_Size; j++ ){
pass_Qu[( to_Sort[j] / cur_Factor ) % max_Digits].push( to_Sort[j] );
}
for( j = k = 0; j < max_Digits; j++ ){
while( !pass_Qu[j].empty() ){
to_Sort[k++] = pass_Qu[j].front();
}
}
}
return 0;
}
Thank you.