-sharpinclude<stdio.h>
-sharpinclude<stdlib.h>
-sharpinclude<time.h>
int main()
{
int a[10][10];
srand(time(NULL));
int i,j;
for(i=0;i<10;iPP)
{
for(j=0;j<10;jPP)
{
a[i][j]=rand()%10;
printf("%d\t",a[i][j]);
}
printf("\n");
}
printf("\n");
FILE *fp=fopen("./a_matrix","wb+");
if(fp)
{
int size=fwrite(a,sizeof(a),1,fp);
if(size==1)
{
int b[10][10];
fread(b,sizeof(b),1,fp);
if(feof(fp))
{
for(i=0;i<10;iPP)
{
for(j=0;j<10;jPP)
{
printf("%d\t",b[i][j]);
}
printf("\n");
}
}
}
fclose(fp);
}
return 0;
}
the result of a compilation run using gcc is
8 3 5 9 4 9 0 5 27
4 2 2 3 4 9 4 6 3 7
6 7 1 1 4 4 7 0 3 5
9 40 6 3 5 7 5 22
4 8 4 6 7 8 6 3
5 3 0 6 4 6 2 4 7 6
1 8 0 2 7 5 9 4 3 3
6 9 2 3 8 6 7 7 4 0
0 25 2 8 9 9 3 5 6
9 7 4 1 9 8 0 8 3
2 32546 510347552 510347552 32766 30 510347536 32766
00-769542344 32546 00 10-769542384 32546
00 1700966438 0-769541480 32546 510347704 32766 510347760 32766
-769542384 32546 00-771763729 32546 00 510347760 32766
00 00-769542384 32546-774158457
00 510347536 32766 510347552 32766-769541480 32546 32546
0 510347568 32766-1000 510943848 32766
-769542384 32546 000 1970169159 0
9 0-771799456 32546 510347720 32766 15775231 01 0
-449672227 22095-771741280 32546 00-449672304 22095-449673168 22095
I don"t understand why there is such a result