-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
52 lines (48 loc) · 1.05 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
#include <stdio.h>
#include <string.h>
struct running { int val;
int retval;
};
void println(char * text);
void mainloop(struct running *m);
int main(int argc, char *argv[]) {
struct running m;
m.val = 1;
m.retval = 0;
println("Welcome to TildeBlog!");
while (m.val) {
mainloop(&m);
}
return m.retval;
}
void mainloop(struct running *m) {
char * sep = "---------------------";
println(sep);
println("1. Read your blog");
println("2. Write a post (NYI)");
println("3. Exit");
printf("Choice: ");
char choice[500];
scanf("%s", choice);
if (strcmp(choice,"3") == 0) {
println(sep);
m->val = 0;
}
if (strcmp(choice,"2") == 0) {
println("NYI");
println(sep);
m->retval = -1;
m->val = 0;
}
if (strcmp(choice,"1") == 0) {
println("blahblahblah's blog");
println("1. Test");
println("Created on 1970-01-01 00:00:00 UTC+0:00");
println("");
println("This is a test to see if this works.");
println("Eventually, you will be able to set your own title and write your own posts.");
}
}
void println(char * text) {
printf("%s\n",text);
}