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 m(n)=(char*)malloc(n*sizeof(char) )
- typedef struct
- {
- int day;
- int month;
- int year;
- }date;
- typedef struct
- {
- char* university;
- char* faculty;
- char* group;
- }dean;
- typedef struct
- {
- char* first_name;
- char* last_name;
- date stude;
- char* city;
- dean ind;
- }student;
- int menu()
- {
- int choice=0;
- int res = 0;
- printf("1. enter general information \n");
- printf("2. enter information for dean \n");
- printf("3. enter all information \n");
- printf("4. display all information \n");
- printf("5. exit\n");
- printf("Input: ");
- scanf("%d", &choice);
- res=input(choice);
- return res;
- }
- int input(int choice)
- {
- int number=0;
- student stu ;
- dean indent ;
- if (choice == 1)
- {
- printf("number of student: ");
- scanf("%d", number);
- student people[N];
- printf("Enter first name: ");
- stu.first_name = (char*)malloc(sizeof(char) * 100);
- gets(stu.first_name);
- printf("Enter last name: \n");
- stu.last_name = (char*)malloc(sizeof(char) * 100);
- gets(stu.last_name);
- printf("Enter age:(day, month, year) \n");
- // scanf("%d ,%d, %d \n", &student.stude.day, &student.stude.month, &student.stude.year);
- printf("Enter city: \n");
- stu.city = (char*)malloc(sizeof(char) * 100);
- gets(stu.city);
- }
- 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 \t city:%s \n", stu.first_name, stu.last_name ,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)
- {
- int beg=1;
- while (beg>0)
- {
- beg=menu();
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement