-
Notifications
You must be signed in to change notification settings - Fork 0
/
Input.c
49 lines (39 loc) · 1.39 KB
/
Input.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
44
45
46
47
48
49
#include "Input.h"
extern Input* readFile(char* fileName, Input* input, FILE outputFile) {
char buffer[150];
FILE* inputFile = NULL;
if ((inputFile = fopen(fileName, "r")) == NULL) {
printf("Input File Not Found / Can't Be Accessed");
exit(-1);
}
else {
while (!feof(inputFile)) {
fgets(buffer, 100, inputFile);
if (buffer[0] != '#' && strlen(buffer) > 1) {
sscanf(buffer, "maxQueueLength %d", &(input->maxQueueLength));
sscanf(buffer, "numServicePoints %d", &(input->numServicePoints));
sscanf(buffer, "closingTime %d", &(input->closingTime));
sscanf(buffer, "averageNewCustomersPerInterval %d", &(input->averageNewCustomersPerInterval));
}
}
if (input->maxQueueLength == 0) {
printf("Parameter maxQueueLength not found");
}
if (input->numServicePoints == 0) {
printf("Parameter numServicePoints not found");
}
if (input->closingTime == 0) {
printf("Parameter closingTime not found");
}
if (input->averageNewCustomersPerInterval == 0) {
printf("Parameter averageNewCustomersPerInterval not found");
}
fprintf("--------- Parameters read from %s ---------");
fprintf("maxQueueLength: %d", input->maxQueueLength);
fprintf("numServicePoints %d", input->numServicePoints);
fprintf("closingTime %d", input->closingTime);
fprintf("averageNewCustomersPerLine %d", input->averageNewCustomersPerInterval);
fclose(inputFile);
return input;
}
}