Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
William Sha
ai01_tp1
Commits
29f997d4
Commit
29f997d4
authored
Nov 20, 2017
by
William Sha
Browse files
Minor fix for remove still in bug
parent
bb79e679
Changes
2
Show whitespace changes
Inline
Side-by-side
main.c
View file @
29f997d4
...
...
@@ -68,7 +68,7 @@ int main()
break
;
case
TOKEN_DEL_NB_SPC
:
remove_element
(
NULL
,
0
);
remove_element
(
default_list
,
2
);
break
;
case
TOKEN_SRT_LI_ASC
:
...
...
tp3.c
View file @
29f997d4
...
...
@@ -109,7 +109,7 @@ int insert_after_position(List* list, char* str, int p){
int
remove_element
(
List
*
list
,
int
p
){
if
(
DEBUG
)
printf
(
"REMOVE_ELEMENT
\n
"
);
if
(
!
*
list
){
if
(
!
list
){
printf
(
"List pointer is null.
\n
"
);
return
-
1
;
}
...
...
@@ -120,13 +120,18 @@ int remove_element(List* list, int p){
}
int
n
=
1
;
// position du parcours
Element
*
e
=
list
->
head
,
suppr
;
Element
*
e
=
list
->
head
;
Element
*
suppr
;
if
(
DEBUG
)
printf
(
"FLAG 1
\n
"
);
/*
e sera utilisé pour pointer la bonne position, suppr sera utilisé pour "manger le nombre" (désallocation)
e will be used to focus on the right place, suppr will be used to "eat the number"
*/
while
(
n
<
p
){
// tant que l'on est pas arrivé au Pème chiffre
if
(
DEBUG
)
printf
(
"WHILE
\n
"
);
do
{
e
=
e
->
next
;
}
while
(
e
->
data
!=
NULL
);
// on parcoure la liste jusqu'au prochain nombre
...
...
@@ -142,6 +147,7 @@ int remove_element(List* list, int p){
*/
do
{
if
(
DEBUG
)
printf
(
"DO2
\n
"
);
e
->
next
=
suppr
->
next
;
free
(
suppr
->
data
);
free
(
suppr
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment