QUOTE(coolindienc @ 3 Dec, 2006 - 06:36 PM)

I tried to fill array from a file and an array by first column and then by second column. However, I am receiving several errors when I try to compile program. Please help. I am getting all my errors in my "fillArray" function. Please someone help me to find what is the problem. All my errors are basically expect me to make change in syntex and constructor and deconstructor. I also put line number in my code where I receive errors. However, I do not believe that I can be making these many mistakes for syntex. I must be missing something simple. My text file and my code are as below:
Thanks a million in advance!!!!
Text file
QUOTE
2 5 1050
5 17 1200
3 12 1225
2 23 1300
3 6 1140
3 3 1110
2 4 1420
2 1 1360
5 14 1225
5 11 1380
5 10 1470
2 2 1565
3 8 1445
5 7 1387
3 9 1128
2 16 1488
CODE
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
//void sortem()
void fillarray()
short employees[100][3]; //Line 13
int row, int col, int i, int sizeoffile; //Line 14
ifstream inFile;
inFile.open ("DataSheet.txt"); //Line 17
sizeoffile = 0; //Line 18
for (row=0; row<100; row++) //Line 19
{
for (col=0; col<3; col++)
inFile >>(employees[row][col]);
if(inFile.fail())break;
sizeoffile++;
}
inFile.close(); //Line 26
} //Line 27
void sortem(short employees[100][3], int elems)
{
ifstream inFile;
inFile.open ("DataSheet.txt");
int i, minIndex, minValue;
for (i=0; i<(elems-1); i++)
minIndex = i;
minValue = (employees[i][]);
for (int index=i+1;index<elems; index++)
{
if (employees[index][] < minValue)
{
minValue = employees[index][];
minIndex = index;
}
}
employees[minIndex][] = employees[index][];
employees[i][]=minValue;
}
int main ()
{
int values[size1][size2] = employees[100][3];
fillarray (values, size1, size2);
sortem(values, size1, size2);
fillarray (values, size1, size2);
system ("pause");
return 0;
}
First of all, you should post the error messages too. But you should fix this first:
CODE
void fillarray()
short employees[100][3]; //Line 13
int row, int col, int i, int sizeoffile; //Line 14
ifstream inFile;
this should be
CODE
void fillarray() {
short employees[100][3]; //Line 13
int row, col, i, sizeoffile; //Line 14
ifstream inFile;
You forgot a { and the extra int's on line 14 should be taken out. Make those changes and then post any other errors and line numbers you get.