-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
53 lines (43 loc) · 1.31 KB
/
main.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
50
51
52
53
// Including C header files.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Including local header files.
#include "include/help.h"
#include "include/mode.h"
#include "include/heads.h"
#include "include/conversion.h"
#include "include/operational.h"
// Defining macros.
#define MAX 18
#define RUNNING 1
// Main function
int main(int argc, char **argv){
/*
Main function for our calculator.
From the "mode" and "heads" header file, this function
prints the title and the credits, then scanning
the user input as mode then running the verified
and matched mode function.
*/
char mode[MAX]; // Mode string variable.
start_head(); // Printing the title and credits.
// Main event loop
while (RUNNING) {
printf("Mode: ");
scanf("%s", mode);
// verifying the user's mode using the
// in_modes function from the "mode" header file.
if (!in_modes(mode)) {
printf("Invalid Mode (%s).\n", mode);
};
if (!strcmp(mode, "exit")) {
break;
};
// Matching the user's mode to the evaluated
// mode and running it using the eval_mode and
// get_mode functions from "modes" header file.
eval_mode(get_mode(mode));
}
return 0; // Return a success code.
}