i need that every user input is character it will ask again to enter number until the user's input is correct.my program does not seems to apply the proper condition any help guys?
#include<stdio.h>
#include<stdlib.h>
#define p printf
#define s scanf
#include<ctype.h>
struct node
{
int data;
struct node *link;
};typedef struct node *nodepointer;
void push(nodepointer &top,int number)
{
nodepointer newnode,temp;
newnode=(nodepointer)malloc(sizeof(struct node));
newnode->data=number;
newnode->link=NULL;
if(top==NULL)
{
top=newnode;
}
else
{
temp=top;
while(temp->link!=NULL)
temp=temp->link;
temp->link=newnode;
}
}
void display(nodepointer top)
{
if(top==NULL)
{
p("\nNothing to display");
}
else if(top!=NULL)
{
while(top->link!=NULL)
{
p("\n%i",top->data);
top=top->link;
}
p("\n%i",top->data);
}
}
main()
{
nodepointer top;
top=NULL;
int number;
int choice;
int found=0;
char operators;
do
{
p("\n[1].Push");
p("\n[2].Display");
p("\n[3].Add operator");
p("\nKey choice: ");
fflush(stdin);
s("%i",&choice);
switch(choice)
{
case 1:
do
{
p("\nEnter number: ");
fflush(stdin);
s("%i",&number);
push(top,number);
if(isalpha(number))
found=1;
else
found=0;
}while(found==1);
break;
case 2:
display(top);
break;
}
}while(1==1);
system("pause");
}

This article has been dead for over six months. Start a new discussion instead.