Linked list, no out put,help



dear group,

/*Linked list in C*/


#include<stdio.h>
#include<stdlib.h>

struct node
{
int data;
struct node *next;
}a;

void init(int data)
{
struct node *p;
p = malloc(sizeof *p);
if(!p)
{
printf("mem error");
exit(EXIT_FAILURE);
}

a.data = data;
a.next = NULL;
p = &a;
}

int main(void)
{
unsigned int i,j;
for(j=0;j<6;j++)
{
scanf("%d",&i);
init(i);
}
while(a.next != NULL)
{
for(j=0;j<6;j++)
printf("value = %d\n",a.data);

}
return 0;
}

This is not the first time I am implementing a linked list.But every
time I
try to do that I get no out put. The above is the same situation. The
above
don't print any out put. Can any one tell me why.

[OT]
I can not configure news reader in my company. Same with the mail
reader. Though I use win98 the pop and nntp server simply functioning.
So I go for the ugly google.
[/OT]

.



Relevant Pages

  • Re: Linked list, no out put,help
    ... struct node *next; ... int main ... That condition evaluates to 0 the first time, and the loop body is never executed. ... This is not professional code. ...
    (comp.lang.c)
  • radix sort
    ... struct node *next; ... void freelist; ... int large_dig; ... kth digit of all no:s */ ...
    (comp.programming)
  • LinkedList Pointer (REPOST - diff version)
    ... struct node * next; ... No problem until you are dealing with a pointer variable. ... void Push(struct node** headRef, int newData); ... Given an int and a reference to the head pointer (i.e. a struct ...
    (comp.lang.c)
  • LinkedList Pointer (REPOST - diff version)
    ... struct node * next; ... No problem until you are dealing with a pointer variable. ... void Push(struct node** headRef, int newData); ... Given an int and a reference to the head pointer (i.e. a struct ...
    (comp.lang.c)
  • Re: free memory question
    ... pointer (ptr) dynamically allocated in function "test_free"? ... struct node* y; ... int main ... struct node* calc = NULL; ...
    (comp.lang.c)