forked from ghewgill/nwr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.cpp
More file actions
34 lines (33 loc) · 712 Bytes
/
plot.cpp
File metadata and controls
34 lines (33 loc) · 712 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
32
33
34
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *inf = fopen(argv[1], "rb");
if (inf == NULL) {
perror("fopen");
exit(1);
}
FILE *outf = fopen("plot.tmp", "w");
if (outf == NULL) {
perror("fopen");
exit(1);
}
int s = 0;
for (;;) {
char buf[4096];
int n = fread(buf, 1, sizeof(buf), inf);
if (n == 0) {
break;
}
for (int i = 0; i < n/2; i++) {
fprintf(outf, "%d %d\n", s, *(short *)&buf[i*2]);
s++;
if (s >= 400) goto bail;
}
}
bail:
fclose(outf);
fclose(inf);
system("gnuplot plot.gpl");
return 0;
}