| |

VerySource

 Forgot password?
 Register
Search
View: 508|Reply: 1

Novice, ask C

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-6 08:00:01
| Show all posts |Read mode
#include <stdio.h>
int main (void)
{
char cA;
printf ("Please enter any uppercase and lowercase letters:");
scanf ("% c",&cA);
while ((cA> = 65&&cA <= 91) || (cA> = 97&&cA <= 123))
{
if (cA> = 65&&cA <= 91)
{
cA = cA + 32;
}
printf ("% c", cA);
printf ("\n");
printf ("Please enter any uppercase and lowercase letters:");
scanf ("% c",&cA);
}
return 0;
}
Why doesn't the input in this loop work?
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-5-23 09:45:01
| Show all posts
Add a sentence after both scanf ("% c",&cA); fflush (stdin);
Problems with residual data in the buffer.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list