-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmy_stdio.3.c
More file actions
61 lines (56 loc) · 1.4 KB
/
my_stdio.3.c
File metadata and controls
61 lines (56 loc) · 1.4 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*******************************************************************************
*
* File Name : my_stdio.3.c
* Created By : Thomas Aurel & Loïc Delaveau
* Creation Date : April 22th, 2015
* Last Change : April 23th, 2015 at 01:01:47
* Last Changed By : Thomas Aurel
* Purpose :
*
*******************************************************************************/
#include <stddef.h>
#include <stdlib.h>
#include "my_stdio.h"
charlist * addItem(char c, charlist *list){
charlist *newlist = NULL;
if((newlist = createItem(c)) == 0){
my_puts("Error: on createList()");
return NULL;
}
if(list != NULL){
charlist *lastlist = lastItem(list);
lastlist->next = newlist;
} else {
list = newlist;
}
return list;
}
charlist * concatItem(charlist *list, charlist *newlist){
if(list != NULL){
charlist *lastlist = lastItem(list);
lastlist->next = newlist;
} else {
list = newlist;
}
return list;
}
charlist * createItem(char c){
charlist *newlist = NULL;
newlist->value = c;
newlist->next = NULL;
return newlist;
}
charlist * lastItem(charlist *list){
while(list->next != NULL){
list = list->next;
}
return list;
}
int listSize(charlist *list){
int i = 0;
while(list != NULL){
i += 1;
list = list->next;
}
return i;
}