- English -
Resident Freddy
- Joined
- Apr 7, 2004
- Messages
- 5,263
Need some more C help from whoever has the knowledge if possible.
im trying to open the text file, print it in2 a 2d array under 1 function. Can you see where its going wrong? Try not to mind the layout its all a bit muddled really while i work out how to do it,
thanks
Code:
void read(char place[11][11], int dist[10][10]) {
char Locations[21];
int a, b;
FILE *in_file;
in_file = fopen("Locations.txt","r");
if (in_file == NULL) {
printf("\nCannot Open File, Please Check Filename Is Correct %s\n", &Locations);
exit(0);
}
else if (in_file != NULL) {
printf("File Opened Successfully", &Locations);
printf("\n");
}
for (a=0; a <= place;a++) {
for (b=0; b <= dist;b++){
fscanf(Locations, "%d ", &Locations[a][b]);
printf("%-4d ", &Locations[a][b]);
}
printf("\n");
}
fclose(in_file);
}
im trying to open the text file, print it in2 a 2d array under 1 function. Can you see where its going wrong? Try not to mind the layout its all a bit muddled really while i work out how to do it,
thanks