Hi,
I try to make a program to check if a linked list is palindrome, but I have one problem.
When I compile, I don't know why but it doesn't show me the four lists.

The code show like this :
Code:
#include <stdio.h>#include <stdlib.h>
#define ZERO 0
#define ONE 1
struct Node
{
char character;
struct Node *next;
};
struct Node *createList(char *charPtr, int nr_01);
void displayList(struct Node *head);
int main()
{
struct Node *head = NULL;
int nr_01 = 14, nr_02 = 14, nr_03 = 15, nr_04 = 16;
char ch_01[] = "ABCDEFGGFEDCBA";
char ch_02[] = "ABCDEFGJFEDCBA";
char ch_03[] = "ABCDEFGJGFEDCBA";
char ch_04[] = "ABCDEFGJTGFEDCBA";
/// Function to create a linked list
head = createList(ch_01, nr_01);
/// Function to display the list
displayList(head);
head = createList(ch_02, nr_02);
displayList(head);
head = createList(ch_03, nr_03);
displayList(head);
head = createList(ch_04, nr_04);
displayList(head);
return 0;
}
struct Node *createList(char *charPtr, int nr)
{
struct Node *head = NULL, *current = NULL, *temp = NULL;
int i, Flag = ONE;
for(i=0; i<nr; i++)
{
if(Flag == ONE)
{
head = (struct Node*)malloc(sizeof(struct Node*));
if(head == NULL)
printf("\n Memory allocation failed! \n");
else
{
head->character = charPtr[0];
head->next = NULL;
temp = head;
}
Flag = ZERO;
}
else
{
current = (struct Node*)malloc(sizeof(struct Node*));
if(current == NULL)
printf("\n Memory allocation failed! \n");
else
{
/// store the character array's elements in character
current->character = charPtr[i];
current->next = NULL;
temp->next = current;
temp = temp->next;
}
}
}
return head;
}
void displayList(struct Node *head)
{
struct Node *current = head;
printf("\n ");
while(current != NULL)
{
printf("%c->", current->character);
current = current->next;
}
printf("NULL\n");
}