-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinput.cpp
35 lines (29 loc) · 1004 Bytes
/
input.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
#include "input.h"
#include "global.h"
/* -------------------------------------------------------------------
* Constructor. If flag = 1, output user inputs as script.inp
* ---------------------------------------------------------------- */
UserInput::UserInput(int flag)
{
fp = NULL;
if (flag) fp = fopen("script.inp", "w");
return;
}
/* -------------------------------------------------------------------
* Deconstructor. Output user inputs as required and clear workspace.
* ---------------------------------------------------------------- */
UserInput::~UserInput()
{
if (fp) fclose(fp);
fp = NULL;
}
/* -------------------------------------------------------------------
* Read stdin and keep a record of it.
* ---------------------------------------------------------------- */
void UserInput::read_stdin(char *str)
{
fgets(str, MAXLINE, stdin);
if (fp) fprintf(fp, "%s", str);
return;
}
/* ---------------------------------------------------------------- */