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

Merge remote-tracking branch 'origin/master'

parents b18d4aa1 83d20940
......@@ -108,16 +108,15 @@ int insert_after_position(List** list, char* str, int p){
if (p == 1 || length == 0){
insert_beginning_list(list, str);
return 1;
return 0;
}
if (p == length || ((((*list)->head != NULL) & ((*list)->head == (*list)->tail)))){
insert_end_list(list, str);
return 1;
return 0;
}
Element* parcour = (*list)->head;
printf("1\n");
int compteur = 0;
while(p != compteur){
......@@ -126,16 +125,13 @@ int insert_after_position(List** list, char* str, int p){
compteur++;
}
//a la sortie parcour est à l'element de delimitation de l'element p
printf("2\n");
List *tempList;
initialize(&tempList);
insert_empty_list(&tempList, str);
printf("3\n");
tempList->tail->next = parcour->next;
parcour->next = tempList->head;
free(tempList);
//display(*list);
return 1;
return 0;
}
int remove_element(List* list, int p){
......@@ -143,8 +139,10 @@ int remove_element(List* list, int p){
printf("List pointer is null.\n");
return -1;
}
int length;
length = lengthList(list);
if(p <= 0){
if(p <= 0 || p > length){
printf("The provided value for the position is incorrect.\n");
return -1;
}
......
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