i wrote this programme to read from an input file into an array but the thing is i want to read each line in the input file into a different array where my programe reads every thing in the input file into one array....... can any one help with that
Code:
#include<stdio.h>
#include<stdlib.h>
#define nrows 3
#define ncols 5
main(){
int i,j;
int taxi_location[nrows][ncols];
FILE *data;
data=fopen("inputdata.c","r");
if (data==NULL){
printf("Error: can't open input file\n");
exit(1);
}
for(i=0;i<nrows;i++){
for(j=0;j<ncols;j++){
fscanf(data,"%d",&taxi_location[i][j]);
}
}
//print array//
printf("array is \n");
for(i=0;i<nrows;i++){
for(j=0;j<ncols;j++){
printf("%d",taxi_location[i][j]);
}
}
}
my input files contan
1 2 3 4 5
3 5 7 8 9
1 3 4 6 7