-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
74 lines (65 loc) · 2.01 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
#include "functions.h"
#include "linked_list.h"
#include "objects.h"
#include "user_functions.h"
#include <stdio.h>
int main(void) {
twitter twitter = initialise_twitter();
puts("---- Welcome to Twitter! ----\n\n");
create_account(&twitter);
char *buffer = malloc(sizeof(char));
int choice = 1;
while (choice != 9) { /* Loops the program until program is ended by the user */
puts("\nWhat do you want to do?\n\n"
"1 - Create a new account\n"
"2 - Log into an existing account\n"
"3 - Print Current User Info\n"
"4 - Post a Tweet\n"
"5 - Get your News Feed\n"
"6 - Follow a user\n"
"7 - Unfollow a user\n"
"8 - Delete this account\n"
"9 - Exit Twitter\n"
"\n"
"Please select a number corresponding to one of the options above\n");
scanf("%c", buffer);
fflush(stdin); /* This function doesn't seem to work in Linux so don't use Linux i guess. */
choice = atol(buffer);
switch (choice) { /* Switch Statement for all of the choices outlined above */
case 1:
create_account(&twitter);
break;
case 2:
login(&twitter);
break;
case 3:
print_user_info(&twitter);
break;
case 4:
postTweet(&twitter);
break;
case 5:
getNewsfeed(&twitter);
break;
case 6:
follow(&twitter);
break;
case 7:
unfollow(&twitter);
break;
case 8:
remove_users_tweets(&twitter);
delete_current_user(&twitter);
break;
case 9:
exit_twitter();
break;
case -1: /* secret hidden user function ooh hooh */
print_all_tweets(&twitter);
break;
default:
puts("Sorry, that was not a valid command.\n");
}
}
return 0;
}