Hello
Why my program can't display a table???
what's wrong in my program?
thnak
TABLE:
0123 1.23 23 20 20
0234 2.34 34 50 25
3456 34.56 56 50 10
4567 45.67 7 10 5
5678 6.78 75 75 25
#include<stdio.h>
#include<stdlib.h>
#define ROW 5
#define COL 5
void open_file(int[][COL]);
void display_table(int[][COL]);
int main(void)
{
int table[ROW][COL];
open_file(table);
display_table(table);
return 0;
}
/****************************** OPEN FILE ******************/
void open_file(int table[ROW][COL])
{
FILE *fp;
int row = 0;
if(!(fp=fopen("kk7.txt", "r")))
{
printf("\nCANNOT opening file kk7.txt\n");
exit(EXIT_FAILURE);
}
while(fscanf(fp, "%d%f%d%d%d", &table[row][0], &table[row][1], &table[row][2],
&table[row][3], &table[row][4]
)!=EOF)
{row++;}
fclose(fp);
}
/****************************** DISPLAY TABLE ******************/
void display_table(int table[ROW][COL])
{
int row, col;
for(row=0; row<ROW; row++)
{
for(col=0; col<COL; col++)
{
printf("%d ", table[row][col]);
}
printf("\n");
}
return;
}