hey guys so i was doing what commontater said and i remade the program i was suppose to modify(not make). its working to an extent that it prints my error message even if the input is within the bounds. the program should print the correct statement if it is from a-z or A-Z anything else gets the error message except for the ";". i think the return(enter) key is making the error output even if the input is within the bounds. how do i make it ignore the return key as an error?
Code:#include <stdio.h> int main() { int ch; while((ch=getchar())!=EOF) { if((ch>='a' && ch<='z')||(ch>='A' && ch<='Z')&&(ch=='\r')) printf("The command is: %c\n",ch); else if(!(ch>='a' && ch<='z')||(ch>='A' && ch<='Z') { printf("Error: %c is not a letter.\n", ch); } } }



1Likes
LinkBack URL
About LinkBacks



