-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.c
More file actions
42 lines (37 loc) · 721 Bytes
/
Copy pathqueue.c
File metadata and controls
42 lines (37 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "queue.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void init(queue* l){
l->front=NULL;
l->rear=NULL;
}
int isEmpty(queue*l){
return l->front==NULL;
}
void add(queue*l,char*a){
node* tmp=(node*)malloc(sizeof(node));
strcpy(tmp->a,a);
tmp->next=NULL;
if(!l->front){
l->front=tmp;
l->rear=tmp;
}
else{
l->rear->next=tmp;
l->rear=tmp;
}
}
char *del(queue*l){
if(isEmpty(l)){
return " ";
}
else{
char *string=(char*)malloc(sizeof(char)*100);
string=strcpy(string,l->front->a);
node*tmp=l->front;
l->front=l->front->next;
free(tmp);
return string;
}
}