Hi,
I am writing a problem that only works when a certain character is entered (either A, B, or C), and if that character is not entered, the program will loop around until A,B , or C is entered. So i tried the following code segment below, but even when i enter A,B, or C the while loop still continues. Can anyone explain how i can fix this?

Thanks

char b,a;
while (a != 'A' || 'B' || 'C')
{
printf("enter character\n");
scanf("%c",&b);
a=toupper(b)
}

Recommended Answers

All 2 Replies

>>while (a != 'A' || 'B' || 'C')

wrong way to code that while (a != 'A' && a != 'B' && a != 'C') or this while( a < 'A' || a > 'C')

Thanks, it works fine now.

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.