-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
49 lines (40 loc) · 1.08 KB
/
main.c
File metadata and controls
49 lines (40 loc) · 1.08 KB
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
#include <stdio.h>
#include "memory.h"
int main() {
int total;
printf("Enter total memory size: ");
scanf("%d", &total);
initializeMemory(total);
int choice;
char prog;
int size;
while (1) {
printf("\n1. Allocate\n2. Free\n3. Defragment\n4. Display\n5. Exit\n> ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Enter program name (A-Z): ");
scanf(" %c", &prog);
printf("Enter size: ");
scanf("%d", &size);
allocate(prog, size);
break;
case 2:
printf("Enter program name to free: ");
scanf(" %c", &prog);
freeProgram(prog);
break;
case 3:
defragmentation();
break;
case 4:
displayDisk();
break;
case 5:
printf("Exiting...\n");
return 0;
default:
printf("Invalid choice!\n");
}
}
}