Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <malloc.h>
  4.  
  5. #define N 15
  6. #define m(n)=(char*)malloc(n*sizeof(char) )
  7.  
  8. typedef struct
  9. {
  10. int day;
  11. int month;
  12. int year;
  13. }date;
  14.  
  15. typedef struct
  16. {
  17. char* university;
  18. char* faculty;
  19. char* group;
  20. }dean;
  21.  
  22. typedef struct
  23. {
  24. char* first_name;
  25. char* last_name;
  26. date stude;
  27. char* city;
  28. dean ind;
  29. }student;
  30.  
  31. int menu()
  32. {
  33. int choice=0;
  34. int res = 0;
  35. printf("1. enter general information \n");
  36. printf("2. enter information for dean \n");
  37. printf("3. enter all information \n");
  38. printf("4. display all information \n");
  39. printf("5. exit\n");
  40. printf("Input: ");
  41. scanf("%d", &choice);
  42. res=input(choice);
  43. return res;
  44. }
  45.  
  46. int input(int choice)
  47. {
  48. int number=0;
  49. student stu ;
  50. dean indent ;
  51. if (choice == 1)
  52. {
  53. printf("number of student: ");
  54. scanf("%d", number);
  55. student people[N];
  56. printf("Enter first name: ");
  57. stu.first_name = (char*)malloc(sizeof(char) * 100);
  58. gets(stu.first_name);
  59. printf("Enter last name: \n");
  60. stu.last_name = (char*)malloc(sizeof(char) * 100);
  61. gets(stu.last_name);
  62. printf("Enter age:(day, month, year) \n");
  63. // scanf("%d ,%d, %d \n", &student.stude.day, &student.stude.month, &student.stude.year);
  64. printf("Enter city: \n");
  65. stu.city = (char*)malloc(sizeof(char) * 100);
  66. gets(stu.city);
  67. }
  68. else if (choice == 2)
  69. {
  70. printf("Enter university: ");
  71. indent.university = (char*)malloc(sizeof(char) * 100);
  72. gets(indent.university);
  73. printf("Enter faculty: \n");
  74. indent.faculty = (char*)malloc(sizeof(char) * 100);
  75. gets(indent.faculty);
  76. printf("Enter group: \n");
  77. indent.group = (char*)malloc(sizeof(char) * 100);
  78. gets(indent.group);
  79. }
  80. else if (choice == 3)
  81. {
  82.  
  83. }
  84. else if(choice==4)
  85. {
  86. printf("first name:%s \t last name:%s \t \t city:%s \n", stu.first_name, stu.last_name ,stu.city);
  87. printf("university:%s \t faculty:%s \t group: %s \n ", indent.university, indent.faculty, indent.group);
  88. }
  89. else
  90. {
  91. choice = 0;
  92. }
  93. return choice;
  94. }
  95.  
  96.  
  97. int main(void)
  98. {
  99. int beg=1;
  100.  
  101. while (beg>0)
  102. {
  103. beg=menu();
  104. }
  105. system("pause");
  106. return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement