Creation and Insertion at Specified Index Single Linked List
Creation and Insertion at Specified Index Single Linked List
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
};
if (*headPointer == NULL)
*headPointer = node;
return;
tempNode = *headPointer;
newNode->data = data;
newNode->nextAddr = NULL;
if (pos == 0)
newNode->nextAddr = *p;
*p = newNode;
return;
current = current->nextAddr;
if (current == NULL) {
free(newNode);
return;
newNode->nextAddr = current->nextAddr;
current->nextAddr = newNode;
tempNode = *headPointer;
int main() {
create(&head , 10);
create(&head , 20);
create(&head , 30);
create(&head , 40);
insertPosition(&head , 50 , 2);
printLinkList(&head);
return 0;