Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_ROWS 5
#define MAX_COL 5
struct dozens
{
int arraydozens[MAX_ROWS][MAX_COL];
};
struct units
{
int arrayunits[MAX_ROWS][MAX_COL];
} units[MAX_ROWS][MAX_COL];
int main()
{
//int array[5][5];
int i,j;
struct dozens dozens1 [MAX_ROWS][MAX_COL];
FILE
*myfile; //Δημιουργία δείκτη file για το άνοιγμα αρχείου
myfile=fopen("c:\\treasure.txt","r"); //’νοιγμα του αρχείου
if (myfile==NULL)
{
printf("File doesnt exist");
exit(0);
}
else
for(i=0;i<5;i++)
for(j=0;j<5;j++)
fscanf(myfile,"%d %d", &dozens1[i][j].arraydozens[i][j]);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
printf("array[%d][%d]=%d\n",i,j,dozens1[i][j].arraydozens[i][j]);
fclose(myfile);
return 0;
}
I try to do someting like the above but its wrong. I need to read a file with 25 numbers. Then make a struct that will have an array with dosen of the numbers and the other with the unit of the numbers