I don't know what in the world I'm doing wrong but I'm sick of staring at my screen and debugging over and over again. It's been a while since I've used C++ so I'm a bit rusty. I'm working on a database project that is supposed to implement a hash join algorithm. My problem is basically trying to read a text file which consist of integer numbers that are ordered by row column format (file 1 is 10 x 3 and file 2 is 10 x 4) and each number spaced apart. The output for file one turns out 99% fine besides for the first few numbers and file two outputs a bunch of random numbers no where close to my file. Part of my code is attached below so help me point out what I'm doing wrong. Thanks a ton!
Also, if there is a better way to make a hash-join, please let me know.
int main()
{
int arrayR1[10][3] = {0};
int arrayR2[10][4] = {0};
ifstream fileR2;
ifstream fileR1;
fillArray(fileR1, fileR2, arrayR1, arrayR2);
return 0;
}
void fillArray(ifstream &fileR1, ifstream &fileR2, int arrayR1[][3], int arrayR2[][4])
{
fileR1.open("fileR1.txt");
fileR2.open("fileR2.txt");
for(int i = 0; i < 11; i++){
for(int j = 0; j < 3; j++){
fileR1 >> arrayR1[i][j];
}
}
}
for(int k = 0; k < 11; k++){
for(int l = 0; l < 4; l++){
fileR2 >> arrayR2[k][l];
}
}
}
Data in fileR1:
5 23 42
7 19 32
3 33 28
18 23 42
28 14 17
2 32 7
36 27 14
9 34 42
5 15 27
8 23 5
34 6 20
Output: (I deleted the cout statements for simplicity)
fileR1:
23942
71932
33328
182342
281417
2327
362714
93442
51527
8235
34620
File 2 is just a bunch of random numbers so I left it out for now. Thanks for the help in advance.
Regards,
Simon