Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <malloc.h>
- #define N 15
- //#define memory(n)=(char*)malloc(sizeof(char) * 100)
- typedef struct
- {
- char* university;
- char* faculty;
- char* group;
- }dean;
- typedef struct
- {
- char* first_name;
- char* last_name;
- int age;
- char* city;
- dean ind;
- }student;
- int menu(student stu, dean indent)
- {
- int choice = 0;
- int res = 0;
- printf("1. enter general information \n");
- printf("2. enter information for dean \n");
- printf("3. enter all information (not work)\n");
- printf("4. display all information (dont use)\n");
- printf("5. exit\n");
- printf("Input: ");
- scanf_s("%d", &choice);
- res = input(choice, stu, indent);
- return res;
- }
- int input(int choice, student stu, dean indent)
- {
- int number = 0;
- if (choice == 1)
- {
- //printf("number of student: ");
- //scanf_s("%d", number);
- //student people[N];
- printf("Enter first name: ");
- stu.first_name = (char*)malloc(sizeof(char) * 100);
- gets(stu.first_name);
- getchar();
- printf("Enter last name: ");
- stu.last_name = (char*)malloc(sizeof(char) * 100);
- gets(stu.last_name);
- getchar();
- printf("Enter age: ");
- scanf_s("%d", &stu.age);
- getchar();
- printf("Enter city: ");
- stu.city = (char*)malloc(sizeof(char) * 100);
- gets(stu.city);
- printf("\n");
- }
- else if (choice == 2)
- {
- printf("Enter university: ");
- indent.university = (char*)malloc(sizeof(char) * 100);
- gets(indent.university);
- printf("Enter faculty: \n");
- indent.faculty = (char*)malloc(sizeof(char) * 100);
- gets(indent.faculty);
- printf("Enter group: \n");
- indent.group = (char*)malloc(sizeof(char) * 100);
- gets(indent.group);
- }
- else if (choice == 3)
- {
- }
- else if (choice == 4)
- {
- printf("first name:%s \t last name:%s \t age: %d \t city:%s \n", stu.first_name, stu.last_name, stu.age, stu.city);
- printf("university:%s \t faculty:%s \t group: %s \n ", indent.university, indent.faculty, indent.group);
- }
- else
- {
- choice = 0;
- }
- return choice;
- }
- int main(void)
- {
- student stu = {"p", "p", 0, "p"};
- dean indent = {"p","p","p"};
- int beg = 1;
- while (beg > 0)
- {
- beg = menu(stu, indent);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement