Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

C programming language Tutorial-Page5

Refer following pages to navigate complete C tutorial.
C Language page1
C Language page2
C Language page3
C Language page4
C Language page5

This C programming language tutorial covers linear singly linked list,doubly linked list and circular linked list.

Linked List

There are many types of linked list viz. singly linked list,doubly linked list and circular linked list.

c linked list

EXAMPLE:

struct listnode
{
int data;
struct listnode *next;
};

struct listnode node2 = {20, NULL};
struct listnode node1 = {10, &node2};
struct listnode *head = &node1;

One of the simplest operations is to print the list:
Example:

struct listnode *lp;
for(lp = head; lp != NULL; lp = lp->next)
{
printf("Node: %p data: %d Next Node: %p\n", lp, lp->data, lp->next);
}

This for loop deserves some attention; for loop terminates on lp!=NULL instead of the traditional counter. Also the standard i++ is replaced with accessing the next node. This is the basic loop operation for all linked list.

Singly linked list is the form of data structure where in all the data elements in a list are interconnected and their operations are usually uni-directional.

Doubly linked list is the bidirectional form of data structure connections.

               


Share this page

Translate this page