32 |
*******************************************************************/ |
*******************************************************************/ |
33 |
#include <string> |
#include <string> |
34 |
#include <iostream> |
#include <iostream> |
35 |
|
#include <stdio.h> |
36 |
|
|
37 |
#include "misc.hh" |
#include "misc.hh" |
38 |
|
#include "language/language.hh" |
39 |
|
|
40 |
std::string get_stdin() |
std::string get_stdin(std::string default_choice) |
41 |
{ |
{ |
42 |
std::string answer; |
std::string answer; |
43 |
|
std::string c; |
44 |
std::cin >> answer; |
|
45 |
return answer; |
c = getc(stdin); |
46 |
|
if ((c == "\n") && (default_choice != "")) |
47 |
|
{ |
48 |
|
fflush(stdin); |
49 |
|
return default_choice; |
50 |
|
} |
51 |
|
else |
52 |
|
if ((c == "\n") && (default_choice == "")) |
53 |
|
{ |
54 |
|
fflush(stdin); |
55 |
|
return ""; |
56 |
|
|
57 |
|
} |
58 |
|
else |
59 |
|
{ |
60 |
|
int it = 0; |
61 |
|
do |
62 |
|
{ |
63 |
|
answer.insert(it, c); |
64 |
|
c = getc(stdin); |
65 |
|
it++; |
66 |
|
} |
67 |
|
while (c != "\n"); |
68 |
|
fflush(stdin); |
69 |
|
return answer; |
70 |
|
} |
71 |
} |
} |
72 |
|
|
73 |
int max(int a, int b) |
int max(int a, int b) |
76 |
return a; |
return a; |
77 |
return b; |
return b; |
78 |
} |
} |
79 |
|
|
80 |
|
int check_path(std::string path) |
81 |
|
{ |
82 |
|
FILE *file; |
83 |
|
|
84 |
|
if ((file = fopen(path.c_str(), "r")) == NULL) |
85 |
|
{ |
86 |
|
std::cerr << ERROR6 << std::endl; |
87 |
|
return 1; |
88 |
|
} |
89 |
|
return 0; |
90 |
|
} |