Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
L
linked_list2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Liam E. Roeth
linked_list2
Commits
f2097af6
Commit
f2097af6
authored
Sep 19, 2020
by
Liam E. Roeth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
main.c working
parent
d8f7825d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
31 deletions
+39
-31
llist.c
llist.c
+4
-5
main.c
main.c
+35
-26
No files found.
llist.c
View file @
f2097af6
...
...
@@ -10,7 +10,7 @@ void print_node_at(NODE *head, int pos){
for
(
int
i
=
0
;
i
<
pos
;
i
++
){
currentNode
=
currentNode
->
next
;
}
printf
(
"The data at index %d is: %d"
,
pos
,
currentNode
->
data
);
printf
(
"The data at index %d is: %d
\n
"
,
pos
,
currentNode
->
data
);
}
void
print_node
(
NODE
*
head
){
...
...
@@ -31,14 +31,13 @@ void print_list(NODE *head){
}
}
NODE_ERR
psearch
(
NODE
*
head
,
datatype
data
){
printf
(
"Searching list for: %d"
,
data
);
printf
(
"Searching list for: %d
\n
"
,
data
);
NODE_ERR
node
=
search
(
head
,
data
);
if
(
node
.
node
!=
NULL
)
printf
(
"Location found, index: %d."
,
node
.
err
);
printf
(
"Location found, index: %d.
\n
"
,
node
.
err
);
else
p
rintf
(
"Not found in this list."
);
p
uts
(
"Not found in this list."
);
return
node
;
}
...
...
main.c
View file @
f2097af6
...
...
@@ -2,48 +2,57 @@
#include<stdlib.h>
#include "llist.h"
void
panic
(){
puts
(
"Not implemented yet!"
);
}
void
menu
(
struct
Node
*
head
){
int
choice
;
p
rintf
(
"Welcome to the menu for creation of linked lists.
\n
"
);
p
rintf
(
"Displaying possible actions:
\n
"
);
p
rintf
(
"1. Add at End;
\n
2. Delete Node;
\n
3. Insert Node;
\n
4. Search for value;
\n
5. Print a node;
\n
6. Print full list;
\n
7. Delete list;
\n
8. Exit;
\n
"
);
printf
(
"Please input the number of your desired action: "
);
int
menu
(
struct
Node
*
head
){
int
choice
,
input
;
p
uts
(
"Welcome to the menu for creation of linked lists.
"
);
p
uts
(
"Displaying possible actions:
"
);
p
uts
(
"1. Add at End;
\n
2. Delete Node;
\n
3. Insert Node;
\n
4. Search for value;
\n
5. Print a node;
\n
6. Print full list;
\n
7. Delete list and exit;
"
);
fputs
(
"Please input the number of your desired action: "
,
stdout
);
scanf
(
"%d"
,
&
choice
);
switch
(
choice
)
{
case
1
:
//a
dd at
end
break
;
case
1
:
//a
pp
end
//
break;
case
2
:
//delete node
// break;
case
3
:
//insert
panic
();
break
;
case
3
:
//insert node
break
;
case
4
:
int
val
;
printf
(
"You have selected to search for a value. Please input the value now: "
);
scanf
(
"%d"
,
&
val
);
psearch
(
val
,
*
head
);
break
;
case
5
:
int
node
;
printf
(
"You have selected to print a node. Please input the node index now: "
);
scanf
(
"%d"
,
&
node
);
print_node
(
node
,
*
head
);
case
4
:
//search
fputs
(
"You have selected to search for a value. Please input the value now: "
,
stdout
);
scanf
(
"%d"
,
&
input
);
psearch
(
head
,
input
);
break
;
case
6
:
printf
(
"Printing full list.
\n
"
);
print_list
(
*
head
);
case
5
:
//print node
fputs
(
"You have selected to print a node. Please input the node index now: "
,
stdout
);
scanf
(
"%d"
,
&
input
);
print_node_at
(
head
,
input
);
break
;
case
7
:
//Delete list
case
6
:
//print list
puts
(
"Printing full list."
);
print_list
(
head
);
break
;
case
7
:
//delete list
puts
(
"Deleting the list..."
);
delete_list
(
head
);
return
1
;
}
return
0
;
}
int
main
1
(){
int
main
(){
struct
Node
*
start
=
NULL
;
struct
Node
*
start
;
int
arr
[]
=
{
10
,
20
,
30
,
40
,
50
};
start
=
construct_list
(
arr
,
5
);
while
(
!
menu
(
start
))
;
return
0
;
}
Write
Preview
Markdown
is supported
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