Tag Archives: Displaying Listn

Help with linked list.

By prinsh

#include
#include

struct LinkedList
{
int val;
struct LinkedList *next;
}node;
typedef struct LinkedList Node;
Node *start = NULL;
int create(int i)
{
Node *temp = NULL;
if (start == NULL)
{
start = (Node*)malloc(sizeof(node));
start->val = i;
start->next=NULL;
return 0;
}
else
temp = start;
while(temp != NULL)
{
printf(“Value in temp = %dn”, temp->val);
temp=temp->next;
}
temp = (Node*)malloc(sizeof(node));
temp->val = i;
start->next= temp;
temp->next = NULL;
return 0;
}

void display()
{
Node *temp = NULL;
printf(“Displaying Listn“);
if (start == NULL)
printf(“List is Emptyn”);
else
{
temp = start;
while(temp != NULL)
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums