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
a8084cd1
Commit
a8084cd1
authored
Nov 21, 2017
by
William Sha
Browse files
Fixed display bug, associed to insert function
parent
8147e4ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
tp3.c
View file @
a8084cd1
...
...
@@ -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
)
...
...
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