Reading integers from a file into a 2-dimensional array

I need to get the number from a file into a 2-dimensional array. Here's the code:

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
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <windows.h>
#include <fstream>
#include <cstring>

using namespace std;

int main()
{
  int array[10][10];
  for(int i = 0; i < 10; i++) 
  {
          for(int p = 0; p < 10; p++)
          {
                array[i][p] = 7;  
          }
  }
  
  ifstream input("test.txt", ios::in);
  int iarray[10][10];
  for(int y = 0; y < 10; y++)
  {
          for(int x = 0; x < 10; x++)
          {
                  input >> iarray[y][x];

                  cout << iarray[y][x] << " ";
          }
          cout << endl;
  }
  
  system("PAUSE");
  return 0;
}


It looks like it should run correctly, but when I compile all I get is a series of random numbers. I know it's something to do with line 25, but I just don't know what. And just for reference, this is what test.txt looks like:
1
2
3
4
5
6
7
8
9
10
7777777777
7777777777
7777777777
7777777777
7777777777
7777777777
7777777777
7777777777
7777777777
7777777777
The number 7777777777 is too big for 32 bit integer. Try 64 bit integer
closed account (DSLq5Di1)
The extraction operator (>>) uses whitespace to delimit values, so as coder777 points out, you are reading in the number 7777777777 instead of the desired 7?
Thanks, the white space was what was wrong. I changed the function that created the file to include white spaces, and now it works just fine. Thanks everyone.
Topic archived. No new replies allowed.