nguyentruong98

Untitled

Dec 1st, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. typedef struct Queue
  5. {
  6.       char Name[80], Phone[80], Email[80];
  7.       struct Node *head;
  8.       struct Node *next;
  9. } Queue;
  10. Node *front(Queue q);
  11. {
  12.       if (q.head == NULL)
  13.             return;
  14.       return q.head;
  15. }
  16. Queue* makeQueue()
  17. {
  18.       Queue* q;
  19.       q = (Queue *)malloc(sizeof(Queue));
  20.       q->head = NULL;
  21.       return q;
  22. }
  23. void pop(Queue *q)
  24. {
  25.       Node *tmp;
  26.       if (q.head == NULL)
  27.       {
  28.             printf("ERROR\n");
  29.             return;
  30.       }
  31.       Node *tmp = q.head;
  32.       q.head = q.head->next;
  33.       free(tmp);
  34. }
  35. void push(Queue *q)
  36. {
  37.       Node *iterator;
  38.       if (q.head == NULL)
  39.             return;
  40.       Node *iterator = q.head;
  41.       while (iterator->next != NULL)
  42.       {
  43.             iterator = iterator->next;
  44.       }
  45.       iterator->next = p;
  46.       return;
  47. }
  48. int main()
  49. {
  50.       FILE *f;
  51.       f = fopen("phonebook.txt", "r");
  52.       if (f == NULL)
  53.       {
  54.             printf("ERROR");
  55.       }
  56.       else
  57.       {
  58.             char s1[80], s2[80], s3[80];
  59.             do
  60.             {
  61.                   fscanf(f, "%s %s %s", s1, s2, s3);
  62.                   Node* newNode = makeNode(s1,s2,s3);
  63.             }
  64.             return 0;
  65.       }
Advertisement
Add Comment
Please, Sign In to add comment