Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
761B

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include "utlist.h"
  5. #define BUFLEN 20
  6. typedef struct el {
  7. char bname[BUFLEN];
  8. struct el *next, *prev;
  9. } el;
  10. int main()
  11. {
  12. el *name, *tmp;
  13. el *head = NULL;
  14. char linebuf[BUFLEN];
  15. FILE *file;
  16. file = fopen( "test11.dat", "r" );
  17. if (file == NULL) {
  18. perror("can't open: ");
  19. exit(-1);
  20. }
  21. while (fgets(linebuf,BUFLEN,file) != NULL) {
  22. name = (el*)malloc(sizeof(el));
  23. if (name == NULL) {
  24. exit(-1);
  25. }
  26. strcpy(name->bname, linebuf);
  27. CDL_PREPEND(head, name);
  28. }
  29. /* CDL_SORT(head, namecmp); */
  30. CDL_FOREACH(head,tmp) {
  31. printf("%s", tmp->bname);
  32. }
  33. fclose(file);
  34. return 0;
  35. }