Commit 0d424f97 authored by h702579998's avatar h702579998

Added the functionality for the functionality of the insertatindex function in main.c

parent f58ba3a6
...@@ -7,7 +7,7 @@ void panic(){ ...@@ -7,7 +7,7 @@ void panic(){
} }
int menu(struct Node *head){ int menu(struct Node *head){
int choice, input; int choice, input, index, value;
puts("Welcome to the menu for creation of linked lists."); puts("Welcome to the menu for creation of linked lists.");
puts("Displaying possible actions:"); puts("Displaying possible actions:");
puts("1. Add at End;\n2. Delete Node;\n3. Insert Node;\n4. Search for value;\n5. Print a node;\n6. Print full list;\n7. Delete list and exit;"); puts("1. Add at End;\n2. Delete Node;\n3. Insert Node;\n4. Search for value;\n5. Print a node;\n6. Print full list;\n7. Delete list and exit;");
...@@ -20,7 +20,11 @@ int menu(struct Node *head){ ...@@ -20,7 +20,11 @@ int menu(struct Node *head){
case 2: //delete node case 2: //delete node
// break; // break;
case 3: //insert case 3: //insert
panic(); fputs("You have decided to insert a value at a specific point. Input the node index now: ",stdout);
scanf("%d",&index);
fputs("\nPlease input the value now: ",stdout);
scanf("%d",&value);
insert_node(head, index, value);
break; break;
case 4: //search case 4: //search
fputs("You have selected to search for a value. Please input the value now: ",stdout); fputs("You have selected to search for a value. Please input the value now: ",stdout);
......
Markdown is supported
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