#include <stdio.h>
#include <stdlib.h>
struct node {
char data;
struct node *next;
}*q;
struct node *head = NULL;
struct node *current = NULL;
//display the list
void printList() {
struct node *ptr = head;
printf("\n[head] =>");
//start from the beginning
while(ptr != NULL) {
printf(" %c =>",ptr->data);
ptr = ptr->next;
}
printf(" [null]\n");
}
//insert link at the first location
void insert(char data) {
//create a link
struct node *link = (struct node*) malloc(sizeof(struct node));
//link->key = key;
link->data = data;
//point it to old first node
link->next = head;
//point first to new first node
head = link;
}
int main() {
insert('e');
insert('d');
insert('c');
insert('b');
insert('a');
q=head->next->next;
q->next->next = head->next;
printf("%c\n",q->next->next->next->data);
//lets check all the data items;
printf("%c ",head->data);
printf("%c ",head->next->data);
printf("%c ",head->next->next->data);
printf("%c ",head->next->next->next->data);
printf("%c ",head->next->next->next->next->data);
printf("%c ",head->next->next->next->next->next->data);
return 0;
}