|
-
Sep 20th, 2002, 11:07 PM
#1
Thread Starter
Lively Member
Multiple conditons in a while loop
cType = getche();
while (cType != 'C' || 'c' || 'I' || 'i' || 'A' || 'a')
{
printf ("Code not valid");
printf ("\nPlease re-enter a type (I, C, or A): ");
}
how can i put multiple conditions into a while loop? currently, the loop always comes back false.
-
Sep 21st, 2002, 06:19 AM
#2
You must write each condition separatly:
PHP Code:
char cType = getche();
while (cType!='C' && cType!='c' && cType!='I' && cType!='i' && cType!='A' && cType!='a')
{
printf("Code not valid");
cType = getche();
}
-
Sep 23rd, 2002, 11:32 AM
#3
Frenzied Member
how about
Code:
for(cType = getche();strchr(cType,"AaCcIi")==NULL;cTYpe=getche() )
printf ("Code not valid\nPlease re-enter a type (I, C, or A): ");
-
Sep 24th, 2002, 06:58 AM
#4
nope, strchr expects a string as first argument.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|