-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_input_main.c
More file actions
42 lines (33 loc) · 940 Bytes
/
single_input_main.c
File metadata and controls
42 lines (33 loc) · 940 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
35
36
37
38
39
40
41
42
#include <stdio.h>
#include "puzzle_solver.h"
/* BUILD_SOLUTION is defined by CMakeLists.txt */
#ifndef BUILD_SOLUTION
#error "BUILD_SOLUTION not defined!"
#endif
/* VERBOSE_DEBUG_OUTPUT is probably defined by CMakeLists.txt */
int main(int argc, char* argv[])
{
#ifdef VERBOSE_DEBUG_OUTPUT
printf("Built for solution %d\n", BUILD_SOLUTION);
#endif
const char* DEFAULT_INPUT_FILE = "test_input.txt";
const char* input_file = DEFAULT_INPUT_FILE;
if (argc > 1)
{
input_file = argv[1];
#ifdef VERBOSE_DEBUG_OUTPUT
printf("Using input file: %s\n", input_file);
#endif
}
FILE* input = fopen(input_file, "r");
if (input == NULL) {
printf("ERROR: Failed to open input file!");
return -1;
}
#ifdef VERBOSE_DEBUG_OUTPUT
printf("File opened ...\n");
#endif
int rv = solve_puzzle(input);
fclose(input);
return rv;
}