Commit a8084cd1 authored by William Sha's avatar William Sha
Browse files

Fixed display bug, associed to insert function

parent 8147e4ed
......@@ -44,9 +44,7 @@ void insert_empty_list(List** list, char* str){
i++;
length--;
}
if(i!= 5){
*(e->data+i) = '\0';
}
*(e->data+i) = '\0';
total += i;
e->next = NULL;
if (!(*list)->head)
......@@ -110,12 +108,12 @@ int insert_after_position(List** list, char* str, int p){
int length;
length = lengthList(*list);
if((p <= 0) || (p > length)){
printf("The provided value for the position is incorrect.\n");
printf("The provided value for the position is incorrect. If list is empty, use \"insert_empty_list\" function instead.\n");
return -1;
}
if (p == 1 || ((*list)->head == (*list)->tail) & ((*list)->head == NULL)){
insert_beginning_list(list, str);
if (p == 1 || length == 0){
insert_beginning_list(list, str);
return 1;
}
......@@ -127,7 +125,7 @@ int insert_after_position(List** list, char* str, int p){
Element* parcour = (*list)->head;
printf("1\n");
int compteur = 0;
while(p != compteur){
parcour = parcour->next;
if(parcour->data == NULL)
......@@ -317,7 +315,7 @@ int lengthList (List *list){
}
Element *parcour = list->head;
int compteur = 0;
while(parcour != list->tail){
parcour = parcour->next;
if(parcour->data == NULL)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment