Really tried to look around, used search. Used Google, tried many ways, but I can't figure this out. (And I guess it's really easy for anyone who 'speaks fluent C++'.)
It's a really easy homework, but I have no idea why does it work this way.
Here is the code:
int temp;
string fname;
cout << "Kerem a fajlnevet: ";
cin >> fname;`
ifstream f;
f.open(fname.c_str());
int szam_madar, szam_helyseg;
f >> szam_madar;
f >> szam_helyseg;
int matrix[szam_helyseg * szam_madar];
for (int i = 1; i <= szam_helyseg; i++)
{
for(int j=1; j <= szam_madar; j++)
{
f >> matrix[i*szam_madar + j];
}
}
maximalisHelyseg(matrix,szam_helyseg,szam_madar);`
And the text I'm using at the read:
5 5 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1
It should create a 5x5 array, then fill it up in order.
Now... the result is quite different.
For the first few array member it gives something like 2686048, 4686232 and so on.