我正在尝试编写一个程序来获取一个字符,然后检查并打印它是大写还是小写。然后我希望它继续循环,直到用户输入应该产生消息的“0”。不起作用的是底部的while条件,条件似乎永远不会满足。
#include <stdio.h>
#include <stdlib.h>
int main()
{
int ch,nope; // Int ch and nope variable used to terminate program
do // start 'do' loop to keep looping until terminate number is entered
{
printf("Enter a character : "); // asks for user input as a character
scanf("%c",&ch); // stores character entered in variable 'ch'
if(ch>=97&&ch<=122) { // starts if statement using isupper (in built function to check case)
printf("is lower case\n");
} else {
printf("is upper case\n");
}
}
while(ch!=0); // sets condition to break loop ... or in this case print message
printf("im ending now \n\n\n\n\n",nope); // shows that you get the terminate line
}