-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump.c
37 lines (31 loc) · 805 Bytes
/
dump.c
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
32
33
34
35
36
37
#include <arpa/inet.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "cell.h"
#include "map.h"
int main(int argc, char *argv[]) {
/* Check command-line arguments */
if (argc != 2) {
fprintf(stderr,
"Usage: %s [map]\n\n"
" This program dumps the contents of map.\n",
argv[0]);
return EXIT_FAILURE;
}
/* Open map file */
struct Cell *map = map_open(argv[1], false, true);
for (unsigned char iter = 0; iter < MAX; ++iter) {
for (unsigned char jter = 0; jter < MAX; ++jter) {
for (unsigned char kter = 0; kter < MAX; ++kter) {
struct Cell *cur = map
+ iter * MAX * MAX
+ jter * MAX
+ kter;
printf("%.2hhu %.2hhu %.2hhu %.10u %.6u\n",
iter, jter, kter, ntohl(cur->num), ntohl(cur->avg));
}
}
}
return EXIT_SUCCESS;
}