Advertisement
Guest User

Untitled

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