array coount

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <fstream>
using namespace std;

main()
{
    ifstream inFile;
    ofstream outFile;

    inFile.open ("dice.txt");

    int rolls[300][2];
    int x,y,z = 0;

    for (x = 0;x > 300; x++)
    {
        for (y = 0;y > 1; y++)
            inFile>> rolls[x][y];
        if (rolls[x][0] == rolls[x][1])
            z++;
    }
    cout << z << endl;

    return 0;
}




I have a list 300 * 2 of all int. And want to see how many times 2 numbers reapeat in [x][1] and [x][1]. It comes out of a file. This program does not work why? Sorry if there is any confusion this it is my first post with c++
without looking if there are other issues, the one that jumps out at me is the loops should have "x <= 300" and "y <= 1", not greater than symbols. also, do you really need a loop for 2 file reads?
Topic archived. No new replies allowed.