50 lines
936 B
C
50 lines
936 B
C
#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;
|
|
}
|
|
|