I will hope if you can use it.
It create some elements of linked list and insert a new node after the position
#include <stdio.h>
#include <stdlib.h>
typedef struct le{
int value;
struct le *next;
}listenelement;
// this can create a new element of the linked list
listenelement *insert(int v,int pos, listenelement *first)
{
int i;
listenelement *move, *new;
new = (listenelement*)malloc(sizeof(listenelement));
// adatok bszuras
new->value = v;
//data insert end
new->next = NULL;
if (first == NULL)//emtpy list ?
return new;
for (move = first; move->next != NULL; move = move->next);
// emtpy cycle can find the last element of linked list
move->next = new;
return first;
}
listenelement* insert_pos(int v, int pos, listenelement *l){
listenelement * new;
new = (listenelement*)malloc(sizeof(listenelement));
new->value = v;
for (int i = 0; i < pos; i++){
l = l->next;
}
new->next = l->next;
l->next = new;
}
int delete_elem(int e, listenelement * l){
}
void sort(int m, listenelement * l){
}
int main() {
int i;
listenelement *first = NULL;
listenelement *act;
act = insert(1, 0, first);
insert(5, 0, act);
insert(6, 0, act);
insert(7, 0, act);
//insert after second element
insert_pos(11, 2, act);
insert(7, 0, act);
insert(7, 0, act);
// print the list elements
while (act != NULL){
printf(" content: %d\n", act->value);
act = act->next;
}
return 0;
}