fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4. #include <string.h>
  5. char print (char* x)
  6. {
  7. printf ("%s ", x);
  8. }
  9. struct city
  10. {
  11. char name_f[80];
  12. char name_p[80];
  13. int date;
  14. char genre[80];
  15. struct city *next;
  16. struct city *previous;
  17. };
  18. struct city *head=NULL;
  19. struct city *last=NULL;
  20. struct city *current=NULL; //òåêóùèé ýëåìåíò
  21. struct city *temp=NULL;
  22. struct city *newList=NULL ;
  23. /* Ïðîöåäóðà ñîçäàíèÿ äîáàâëåíèÿ â ñïèñîê */
  24. void add_name(char namef_,char namep_, char date_, char genre_)
  25. {
  26. if(head!=NULL)
  27. {
  28. newList=malloc (sizeof(struct city));
  29. strcpy(newList->name_f,namef_);
  30. strcpy(newList->name_p,namep_);
  31. strcpy(newList->date,date_);
  32. strcpy(newList->genre,genre_);
  33. strcpy(newList->next,NULL);
  34. strcpy(newList->previous,current);
  35. strcpy(current->next,newList);
  36. last=newList;
  37. current=newList;
  38. }
  39. else
  40. {
  41. newList=malloc (sizeof(struct city));
  42. strcpy(newList->name_f,namef_);
  43. strcpy(newList->name_p,namep_);
  44. strcpy(newList->date,date_);
  45. strcpy(newList->genre,genre_);
  46. strcpy(head,newList);
  47. strcpy(newList->next,NULL);
  48. strcpy(newList->previous,NULL);
  49. current=newList;
  50. last=head;//Çàáûëè óñòàíîâèòü!!!
  51. }
  52. }
  53.  
  54. /* Ïðîöåäóðà óäàëåíèÿ óçëà */
  55. void delete_unit()
  56. { newList=head;
  57. if(newList == head->next)
  58. {
  59. free(head); //óäàëåíèå ýëåìåíòà
  60. head=NULL;
  61. }
  62. else
  63. {
  64. head=head->next;
  65. head->previous=NULL;
  66. free(newList);
  67. }
  68. }
  69. /* Ïðîöåäóðà âûâîäà ñïèñêà ñëåâà íàïðàâî */
  70. int count_L()
  71. {
  72. int count;
  73. newList = head;
  74. if(newList == NULL)
  75. {
  76. count = 0;
  77. }
  78. else
  79. {
  80. while(newList != NULL)
  81. {
  82. count=count+1;
  83. newList = newList->next;
  84. }
  85. }
  86. return count;
  87. }
  88. void show_list(void)
  89. {
  90. struct city *info;
  91. info = head;
  92. while(info)
  93. {
  94.  
  95. printf("%s", &info->name_f);
  96. printf("%s", &info->name_p);
  97. printf("%d", &info->date);
  98. printf("%s", &info->genre);
  99. printf("\n");
  100. info = info->next;
  101. }
  102. }
  103. /* Ïðîöåäóðà âûâîäà ñïèñêà ñïðàâà íàëåâî */
  104. void show_list_1(void)
  105. {
  106. struct city *info;
  107. info = last;
  108. while(info)
  109. {
  110. printf("%s", &info->name_f);
  111. printf("%s", &info->name_p);
  112. printf("%d", &info->date);
  113. printf("%s", &info->genre);
  114. printf("\n");
  115. info=info->previous;
  116. }
  117. }
  118.  
  119. /* Òåëî îñíîâíîé ïðîãðàììû */
  120. int main(void)
  121. {
  122. setlocale(LC_ALL,"Russian");
  123. SetConsoleCP(1251);
  124. SetConsoleOutputCP(1251);
  125. char name_f;
  126. char name_p;
  127. char date;
  128. char genre;
  129. int key=-1;
  130. while(key)
  131. {
  132. print("1. Enter name\n");
  133. print("2. Delete name\n");
  134. print("3. Show names\n");
  135. print("4. Show names from end\n");
  136. print("0. Exit\n");
  137. scanf("%d", &key);
  138. switch (key)
  139. {
  140. case 1:
  141. {
  142. printf("Ââåäèòå íàçâàíèå òåàòðà\n");
  143. scanf("%s", &name_f);
  144. printf("Âåäèòå íàçâàíèå ïðåäñòàâëåíèÿ\n");
  145. scanf("%s", &name_p);
  146. printf("Âåäèòå äàòó ïðåäñòàâëåíèÿ\n");
  147. scanf("%d", &date);
  148. printf("Âåäèòå æàíð ïðåäñòàâëåíèÿ\n");
  149. scanf("%s", &genre);
  150. add_name(name_f,name_p,date,genre);
  151. break;
  152. }
  153. case 2:
  154. {
  155. int n = count_L();
  156. if(n == 0)
  157. {
  158. printf("Íåâîçìîæíîó óäàëèòü ýëåìåíòû â ñòåêå 0 ýëåìåíòîâ");
  159. }
  160. else if (n == 1)
  161. {
  162. printf("Íåâîçìîæíîó óäàëèòü ýëåìåíòû â ñòåêå 1 ýëåìåíò");
  163. }
  164. else if (n > 2)
  165. {
  166. delete_unit();
  167. delete_unit();
  168. }
  169. break;
  170. }
  171. case 3:
  172. {
  173. printf("Ñïèñîê ñ ëåâà íà ïðàâî\n");
  174. show_list();
  175. break;
  176. }
  177. case 4:
  178. {
  179. printf("Ñïèñîê ñ ïðàâà íà ëåâî\n");
  180. show_list_1();
  181. break;
  182. }
  183. case 0:
  184. {
  185. printf("Ïîêà\n");
  186. getch();
  187. break;
  188. }
  189. default:
  190. {
  191. printf("Error\n");
  192. getch();
  193. break;
  194. }
  195. if (key==0) break;
  196. }
  197. }
  198. return 0;
  199. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘add_name’:
prog.c:29:9: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
         strcpy(newList->name_f,namef_);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:30:9: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
         strcpy(newList->name_p,namep_);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:31:9: warning: passing argument 1 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
         strcpy(newList->date,date_);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘int’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:31:9: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
         strcpy(newList->date,date_);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:32:9: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
         strcpy(newList->genre,genre_);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:33:9: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
         strcpy(newList->next,NULL);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:33:9: warning: null argument where non-null required (argument 2) [-Wnonnull]
         strcpy(newList->next,NULL);
         ^
prog.c:34:9: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
         strcpy(newList->previous,current);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:34:9: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type [enabled by default]
         strcpy(newList->previous,current);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:35:9: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
         strcpy(current->next,newList);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:35:9: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type [enabled by default]
         strcpy(current->next,newList);
         ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:42:10: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
          strcpy(newList->name_f,namef_);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:43:10: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
          strcpy(newList->name_p,namep_);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:44:10: warning: passing argument 1 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
          strcpy(newList->date,date_);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘int’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:44:10: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
          strcpy(newList->date,date_);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:45:10: warning: passing argument 2 of ‘strcpy’ makes pointer from integer without a cast [enabled by default]
          strcpy(newList->genre,genre_);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘char’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:46:10: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
          strcpy(head,newList);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:46:10: warning: passing argument 2 of ‘strcpy’ from incompatible pointer type [enabled by default]
          strcpy(head,newList);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘const char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:47:10: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
          strcpy(newList->next,NULL);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:47:10: warning: null argument where non-null required (argument 2) [-Wnonnull]
          strcpy(newList->next,NULL);
          ^
prog.c:48:10: warning: passing argument 1 of ‘strcpy’ from incompatible pointer type [enabled by default]
          strcpy(newList->previous,NULL);
          ^
In file included from prog.c:4:0:
/usr/include/string.h:125:14: note: expected ‘char * __restrict__’ but argument is of type ‘struct city *’
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:48:10: warning: null argument where non-null required (argument 2) [-Wnonnull]
          strcpy(newList->previous,NULL);
          ^
prog.c: In function ‘show_list’:
prog.c:95:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->name_f);
     ^
prog.c:96:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->name_p);
     ^
prog.c:97:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
     printf("%d", &info->date);
     ^
prog.c:98:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->genre);
     ^
prog.c: In function ‘show_list_1’:
prog.c:110:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->name_f);
     ^
prog.c:111:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->name_p);
     ^
prog.c:112:5: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
     printf("%d", &info->date);
     ^
prog.c:113:5: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[80]’ [-Wformat=]
     printf("%s", &info->genre);
     ^
prog.c: In function ‘main’:
prog.c:123:5: warning: implicit declaration of function ‘SetConsoleCP’ [-Wimplicit-function-declaration]
     SetConsoleCP(1251);
     ^
prog.c:124:2: warning: implicit declaration of function ‘SetConsoleOutputCP’ [-Wimplicit-function-declaration]
  SetConsoleOutputCP(1251);
  ^
prog.c:147:8: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘char *’ [-Wformat=]
        scanf("%d", &date);
        ^
prog.c:186:29: warning: implicit declaration of function ‘getch’ [-Wimplicit-function-declaration]
                             getch();
                             ^
prog.c: In function ‘print’:
prog.c:8:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/0W0sbw/ccCBdPpy.o: In function `main':
prog.c:(.text.startup+0x34): undefined reference to `SetConsoleCP'
prog.c:(.text.startup+0x40): undefined reference to `SetConsoleOutputCP'
prog.c:(.text.startup+0x1fd): undefined reference to `getch'
prog.c:(.text.startup+0x22d): undefined reference to `getch'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty