-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempreature.c
More file actions
31 lines (30 loc) · 758 Bytes
/
Copy pathtempreature.c
File metadata and controls
31 lines (30 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
int main() {
float t[31][31];
int i, j, k;
FILE * fin, * fout;
fin = fopen("/Users/anishkumar/Downloads/Maxtemp_MaxT_2020.GRD", "rb"); // Input file
fout = fopen("/Users/anishkumar/Downloads/Maxtemp_MaxT_2020.txt", "w"); // Output file
fprintf(fout, "Max Tempereture for 2020\n");
if (fin == NULL) {
printf("Can't open file");
return 0;
}
if (fout == NULL) {
printf("Can't open file");
return 0;
}
for (k = 0; k < 366; k++) {
fread( & t, sizeof(t), 1, fin);
if (k == 105) {
for (i = 0; i < 31; i++) {
fprintf(fout, "\n");
for (j = 0; j < 31; j++)
fprintf(fout, "%6.2f", t[i][j]);
}
}
}
fclose(fin);
fclose(fout);
return 0;
} /* end of main */