Any idea how to make restrictions in link list.
im still confuse
what will i need to make restrictions??
i know the isdigit isalpha etc.
for example i can only enter DIGIT,

for example i can only enter DIGIT

using if else statements?

yes ..ill post my program herehelp me pls =))

this my program
it can access in alpha and loop but after that the another loop cant read the condition if isalpha
help me pls?

#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");
}

next time please put the code between

tags to preserve indentation and and put in number lines to make it a lot easier to read

Now for the code, it doesn't pass the loop with the isalpha conditional because the value of found is not equal to 1 try to make the code less complicated,
just put the isdigit statement at the while condition

I did it but nothing change...
In the first loop the condition isalpha makes worth but in the second loop when i try
the enter number and i enter alpha and the restrictions doesnt work. why??

at your last code, it would always pass that loop if you always initialize variable found back to 1 after the loop

so what will i do..any idea??
i want every time that user's enter character it will ask again to enter number until user's meet the condition.
what if i will put the condition the enter number in my function PUSH?
can u help me please im confuse now

my problem is in link list??im confuse why the 2nd loop does not read the alpha condition but in the first time i enter character it meet the condition

since number is an integer and not a character datatype using isdigit and isalpha wouldn't be possible
To meet your needs the only workaround I can think of is checking the return value of scanf, it returns 1 when a non-digit number is entered

int number;
char enter;

printf("\nEnter number: ");
if(scanf("%d%c", &number, &enter) == 1 || enter != '\n'){ // enter is used to catch the enter key when pressed
    printf("you did not enter a number");   
}
else{
    printf("valid integer followed by enter key\n");
}

though you can't use it in a loop you might as well just ask again for an input when the if condition is met

what is the purpose of &enter?

i cannot get it..can u code it??change it? sorry for being noob =)

what is the purpose of &enter?

check the commented line at the if condition
also try the code to see it for yourself

i cannot get it..can u code it??change it? sorry for being noob =)

I already posted the code for you, all you need to do is manipulate/integrate your program with it

I can't do your homework for you

can u refer me an application for designing my program i mean GUI designs =))

I MEAN LIKE ASCII ART Studio so i can design my program..thats it??

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.