-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon.cpp
48 lines (43 loc) · 1.17 KB
/
common.cpp
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
44
45
46
47
#include "common.hpp"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int output=1;
char fconf[50];
//---------------------------------------------
double readvalue(const char tc[])
{
FILE *ez;
char s[100];
double zs;
fprintf(stderr, "Read configuration file: %s -> ",fconf);
ez=fopen(fconf,"r+");
// printf(".%s\n",fconf);
fscanf(ez,"%s",s);
while (strcmp(s,tc)!=0) // Vergleich ".end"
fscanf(ez,"%s",s);
fscanf(ez,"%s",s);
// printf(" < %s = %s >\n",tc,s);
zs=atof(s);
if (output==1) printf(" < %s = %s >\n",tc,s);
fclose(ez);
return zs;
}
//---------------------------------------------
//---------------------------------------------
void readfilename(char s[], const char tc[])
{
FILE *ez;
fprintf(stderr, "Read configuration file: %s -> ",fconf);
ez=fopen(fconf,"r+");
if (ez==NULL) {
fprintf(stderr, "** Unable to open file: %s\n", fconf);
exit(-1);
}
fscanf(ez,"%s",s);
while (strcmp(s,tc)!=0) fscanf(ez,"%s",s);
fscanf(ez,"%s",s);
if (output==1) printf(" < %s = %s >\n",tc,s);
fclose(ez);
}
//---------------------------------------------