Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "queue.h"
- #include <stdlib.h>
- #include <string.h>
- int enqueue(struct studentqueue *q, const char *name)
- {
- q->name = NULL;
- struct studentqueue *current = q;
- while(current->next != NULL)
- {
- current = current->next;
- }
- current->next = malloc(sizeof(struct studentqueue));
- if(current->next == NULL)
- {
- return 0;
- }
- current->next->name = malloc(strlen(name) + 1);
- if(current->next->name == NULL)
- {
- free(current->next);
- return 0;
- }
- strcpy(current->next->name, name);
- current->next->next = NULL;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement