blob: 4e8670a07509eec95fe8129edaece37b5fa0a4ab (
plain)
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 <string.h>
struct dog {
int age;
int weight;
char color[16];
char name[16];
};
void menu(struct dog atlas) {
int option;
do {
printf("dawg\n");
printf("1. Option 1\n");
printf("2. Option 2\n");
printf("3. Option 3\n");
printf("4. Exit\n");
scanf("%d", &option);
switch (option) {
case 1:
printf("name: %s\n", atlas.name);
break;
case 2:
printf("age: %d\n", atlas.age);
break;
case 4:
printf("exiting...\n");
break;
default:
printf("Invalid option\n");
}
} while (option != 4);
}
int main() {
struct dog atlas;
atlas.age = 7;
atlas.weight = 77;
strcpy(atlas.color, "black");
strcpy(atlas.name, "atlas");
menu(atlas);
return 0;
}
|