#include <stdio.h>
typedef int MAT [4] [4];
main()
{
MAT matA, matB;
int i, j, fd, n = 4;
char *cptr;
puts("\014\n\n ENTER MATRIX ROW BY ROW");
for (i = 0; i < n; ++i)
for(j = 0; j < n; ++j)
scanf("%d", &matA[i] [j] );
fd = creat("mats.data",4);
cptr = matA; /* no cast -- even tho the scalar of matA is 32 */
write(fd, cptr, sizeof(MAT)); /* cptr is taken to be the
pointer to an array of 32 char */
close(fd);
fd = open("mats.data",2);
cptr = matB; /* cptr now points to the other matrix -- no
cast */
read(fd, cptr, sizeof(MAT));
close(fd);
puts("\n\n\n");
for (i = 0; i < n; ++i)
{
for (j = 0; j < n; ++j) /* 4 x 4 matrix of */
printf("%4d", matB[i][j]); /* integers is
output */
putchar('\n'); /* to screen */
}
}