You're code sample doesn't compile.
Assuming that you're trying to read a binary file containing integers in native-byte order, something like the following should do you. Instead of reading it integer, by integer, why not just slurp it in in one fell swoop?
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define ROWS 10
#define COLS 5
void read_array( int buf[ROWS][COLS] )
{
int x = 0 ;
int len = 0 ;
int cnt = ROWS*COLS ; // number of ints we can handle
FILE *fp = fopen("test.dat", "rb" ) ; // open the file for reading in binary mode
if ( NULL == fp )
{
printf ("error \n");
system("pause");
exit (1);
}
printf("slurping the file\n");
len = fread(buf,sizeof(int),cnt,fp) ;
printf( "slurped!\n") ;
printf( "loaded %d full rows" , len/COLS , len%COLS > 0 ? 1 : 0 ) ;
if ( len%COLS > 0 )
{
printf( "and one partial row having %d columns." , len%COLS ) ;
}
printf("\n" ) ;
for ( x = 0 ; x < ROWS ; ++x )
{
int y ;
printf( "row %d: " , x ) ;
for ( y = 0 ; y < COLS ; ++y )
{
printf( "%d " , buf[x][y] ) ;
}
printf( "\n" ) ;
}
return ;
}
int main( int argc, char* argv[] )
{
int buf[ROWS][COLS] ;
memset( buf , (char)0 , sizeof(buf) ) ;
read_array( buf ) ;
return 0;
}