Could you please help me?
what is wrong with this code?
it prints only D->D->D->D (I want A->B->C->D)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
struct node /* Declaration of structure "node" */
{
char letter[1];
struct node *next ;
};
struct node *start = NULL;
main(void)
{
struct node *current = start;
struct node *new_ptr;
new_ptr = (struct node *)malloc(sizeof(struct node));
new_ptr->next = NULL;
strcpy(new_ptr->letter, "A");
start = new_ptr;
current = new_ptr;
new_ptr = (struct node *)malloc(sizeof(struct node));
new_ptr->next = NULL;
strcpy(new_ptr->letter, "B");
current->next = new_ptr;
current = new_ptr;
new_ptr = (struct node *)malloc(sizeof(struct node));
new_ptr->next = NULL;
strcpy(new_ptr->letter, "C");
current->next = new_ptr;
current = new_ptr;
new_ptr = (struct node *)malloc(sizeof(struct node));
new_ptr->next = NULL;
strcpy(new_ptr->letter, "D");
current->next = new_ptr;
current = new_ptr;
current = start;
printf("%s->\n ",new_ptr->letter);
while(current != NULL)
{
printf("%s-> ",new_ptr->letter);
current = current->next;
}
system("PAUSE");
}