The data file is
6 3
6 7 8
1 2 3
7 8 9
3 4 5
8 9 0
1 6 8
------------
#include <stdio.h>
#include <stdlib.h>
int
main (void)
{
int a, b,i=0,j=0, x[i][j];
FILE *f1;
f1 = fopen ("mat1.dat", "r");
fscanf (f1, "%d%d", &a, &b);
printf ("Rows: %d, Columns: %d\n", a, b);
for (int i=0; i<a; i=i+1)
{
for (int j=0; j<b; j=j+1)
{
fscanf (f1, "%d", &x[i][j]);
}
printf ("\n");
}
fclose (f1);
return (0);
}
It doesnt work. How do i read the matrix and ignore the first two values? Is the code correct?
6 3
6 7 8
1 2 3
7 8 9
3 4 5
8 9 0
1 6 8
------------
#include <stdio.h>
#include <stdlib.h>
int
main (void)
{
int a, b,i=0,j=0, x[i][j];
FILE *f1;
f1 = fopen ("mat1.dat", "r");
fscanf (f1, "%d%d", &a, &b);
printf ("Rows: %d, Columns: %d\n", a, b);
for (int i=0; i<a; i=i+1)
{
for (int j=0; j<b; j=j+1)
{
fscanf (f1, "%d", &x[i][j]);
}
printf ("\n");
}
fclose (f1);
return (0);
}
It doesnt work. How do i read the matrix and ignore the first two values? Is the code correct?
Comment