I need help fixing this one error with my code. Below Im going to upload a piece of the code which im having problems with and the output error .
int main()
{
int vals[100];
fstream file;
string line = "----------------------------------------------------\n";
string msg2 = " Please select an option from the above menu --> ";
string menu1 = " [0] Quit \n"
" [1] Generate Rand Array \n"
" [2] Save Array to File \n"
" [3] Load Array from File \n"
" [4] Search Array \n"
" [5] Compute CPU Time \n"
" [6] Display Generated numbers \n"
" [7] Sorted Search \n"
" [8] lkj \n";
int sz;
int max_range= 100;
int min_range= 0;
ofstream fout;
ifstream fin;
int idx;
int val;
long t0, t1;
int op = -1;
while( op != 0)
{
cout << menu1;
cout << msg2 << endl;
cin >> op;
cout << line << endl;
switch( op )
{
case 0: exit(0); break;
case 1:
int sz;
cout << " Please enter size of the array (sz <= 100) --> ";
cin >> sz;
if(sz > 1000){ //MAX_SZ
cout << " The size you entered is not allowed ...\n";
exit(0);
}
else{
int max_range = 100;
int min_range = 0;
for( int i=0; i<sz; ++i){
vals[i] = min_range + rand() % max_range;
}
}
break;
case 2:
float n1, n2;
fout.open("fout.txt");
for( int i=0; i<sz; ++i)
{
fout << vals[i] << endl;
}
fout.close();
break;
case 3:
fin.open("fout.txt");
idx = 0;
while(fin){
fin >> vals[idx];
++idx;
}
sz = idx;
fin.close();
break;
case 4:
cout << " Please enter the value you are looking for --->";
cin >> val;
idx = LinearSearchArray(vals, sz, val);
if( idx > -1)
cout << " The val (" << val << ") was found at index (" << idx << ") \n\n";
else
cout << " The Val (" << val << ") was not found \n\n" ;
cout << "CPU time was" << t1-t0 << "ms\n\n";
case 5:
idx = LinearSearchArray(vals, sz, val);
t1 = clock();
cout << "running time in ms = " << t1-t0 << "\n";
case 6:
for(int i=0; i<sz; ++i)
{
cout << vals[i] << endl;
}
break;
case 7:
void selectionSort( int array[], int size)
{
int startScan, minIndex, minValue;
for(startScan = 0; startScan < (size = 1); startScan++)
{
minIndex = startScan;
minValue = array[startScan];
for(int index = startScan + 1; index < size; index++)
{
if ( array[index] < minValue)
{
minValue = array[index];
minIndex = index;
}
}
array[minIndex] = array[startScan];
array[startScan] = minValue;
}
}
default: cout << "Invalid option...Please try again \n\n";
}
}
return 0;
}
ERRORS:
12hw1.cpp(174): error C2601: 'selectionSort' : local function definitions are illegal
12hw1.cpp(62): this line contains a '{' which has not yet been matched