-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
80 lines (70 loc) · 2.4 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <stdio.h>
#include "headers/text.h"
#include "mem.h"
#include "menu_Main.h"
void help_menu (void);
int main (int argc, char** argv){
char* string = NULL;
unsigned short int dbm = 0;
unsigned int opt;
if (argc == 2){
if (!strcmp (argv [1], "-dbm") || !strcmp (argv [1], "--debug-mode"))
dbm = 1;
else
dbm = 0;
if (!strcmp (argv [1], "-h") || !strcmp (argv [1], "--help"))
help_menu ();
} else if (argc != 1 && argc != 2){
printf ("Invalid arguments passed!!\n");
help_menu();
exit (0);
}
string = mem_alloc (BUFFER, dbm);
//testing (string);
do {
menu_Main ();
printf ("Choose an option:\n");
scanf (" %u", &opt);
switch (opt){
case 0: CLEAR_SCREEN;
exit (0);
case 1: CLEAR_SCREEN;
printf ("Insert a string:\n");
CLEAR_INPUT;
fgets (string, BUFFER, stdin);
if (string [strlen (string) - 1] == '\n')
string [strlen (string) - 1] = '\0';
menu_Strings ();
printf ("Choose an option:\n");
scanf (" %d", &opt);
func_select (opt, STRING_MENU, string);
print_result (string, opt, STRING_MENU);
break;
case 2: menu_Numbers ();
printf ("Choose an option:\n");
scanf (" %d", &opt);
func_select (opt, NUMBERS_MENU, string);
break;
default: printf ("Invalid option!\n");
}
}while (opt != 0);
/*switch (string_cmp (string, "carlo")) {
case 0: printf ("String are equal!\n");
break;
case 1: printf ("Strings are different!\n");
break;
case 2: printf ("Cannot Compare. Sizes mismatch!\n");
break;
default: printf ("Unkown result!\n");
}*/
mem_free (string, dbm);
return 0;
}
void help_menu (void){
CLEAR_SCREEN;
printf ("Help Menu\n");
printf ("Use <./string --debug-mode> or <./string -dbm> to enable debug mode!\n");
printf ("To display this help menu, type <./string --help> or <./string -h>\n");
printf ("Press any key to exit!\n");
getchar ();
}