-
Notifications
You must be signed in to change notification settings - Fork 0
/
diag.c
44 lines (37 loc) · 869 Bytes
/
diag.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
38
39
40
41
42
43
#include<stdlib.h>
#include<stdio.h>
#define MAXINDEX 10
FILE* fps[MAXINDEX];
int last_index = 0;
int diag_init(char* filename) {
if (last_index >= MAXINDEX) {
printf("Diagnostics needs more file pointer space.\n");
exit(0);
}
else {
fps[last_index] = fopen(filename, "w");
if (fps != 0) {
last_index ++;
return last_index-1;
}
else {
printf("Diagnostics could not open new file for writing!\n");
exit(0);
}
}
}
int diag_write(int fpindex, double x, double y) {
fprintf(fps[fpindex], "%lf %lf\n", x, y);
return 0;
}
int diag_write_list(int fpindex, double x, double* y, int size) {
fprintf(fps[fpindex], "%lf", x);
int i;
for (i=0; i<size; i++)
fprintf(fps[fpindex], " %lf", y[i]);
fprintf(fps[fpindex], "\n");
return 0;
}
int diag_end(int fpindex) {
return fclose(fps[fpindex]);
}