>I'm not too keen on posting my code
Then it will be hard to help you with specific code problems later.
>A list of distances, to be read and stored in a multidimensional array
Fixed size or variable? If it's fixed then the program will be easy:
Code:
/*
Assuming file formatted like so:
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20
*/
FILE *in;
double dist[M][N];
double cpm;
int i, j;
/* Open the file for reading */
for ( i = 0; i < M; i++ ) {
for ( j = 0; j < N; j++ )
fscanf ( "%lf", &dist[i][j] );
}
fscanf ( "%lf", &cpm );
/* Close the file */
/* Make changes */
/* Open the file for writing */
for ( i = 0; i < M; i++ ) {
for ( j = 0; j < N; j++ )
fprintf ( "%f ", dist[i][j] );
fprintf ( "\n" );
}
fprintf ( "\n%f\n", cpm );
/* Close the file */