#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

typedef struct Stack
{
    char info;
    struct Stack *next;
}Stack;

Stack *start=NULL;
Stack *cstart=NULL;//variable for copy of stack
Stack *rstart=NULL;//variable for reverse of stack


Stack* push(Stack *, char);
char pop(Stack *);

int main()
{
    char c;
    int flag=0;
    printf("Enter characters :");
    c=getchar();
    while( c !='\n' )
    {     //Checking whether 'c' is a alphabet or not.
         //White space is also not allowed.ASCII of space is 32
        //by writing c!=32 I mean that ASCII of c will not be 32
        if( isalpha(c) && (c!=32) )
        {
            start=push(start,c);
            cstart=push(cstart,c);
        }
        c=getchar();
    }

    while( start!=NULL )
    {
        rstart=push( rstart, pop(start) );

    }

    while( rstart!=NULL )
    {
        if( toupper( pop(rstart) ) == toupper( pop(cstart) )      )
            flag=1;
        else
        {
            flag=0;
            break;
        }

    }

    if(flag==1)
        printf("The string is a palindrome");
    else
        printf("The string is not a palindrome");

    getch();
    return 0;
}

Stack* push(Stack *rec, char info)
{
    Stack *new_rec;
    new_rec=(Stack *)malloc(sizeof(Stack));
    new_rec->info=info;
    new_rec->next=rec;
    rec=new_rec;

    return rec;
}

char pop(Stack *rec)
{
    char ch;
    Stack *temp;
    if(rec==NULL)
        printf("Stack is empty");
    else
    {
        temp=rec;
        ch=temp->info;
        rec=rec->next;
        free(rec);
    }

    return ch;
}

what does it do?
what do you expect it to do?
why do you expect it to do that?
what have you tried to find out why it's not doing what you expect it to do?

See first of all, tell whats wrong with your output...

this program controls whether entered string is palindrome or not

ok, and what is it supposed to do?
We're not going to do your thinking for you, remember.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.