Here is my code!(sorry for my poor english)
#include<stdio.h>
int convert(char ch);
int main(void)
{
char ch=0;
while(ch != 'q')
{
ch=getchar();
ch=convert(ch);
if(ch == -1)
printf("wrong input");
else
putchar(ch);
putchar('\n');
}
return 0;
}
int convert(char ch)
{
if(ch>='A' && ch<='Z')
ch+=32;
else if(ch>='a' && ch<='z')
ch-=32;
else
return -1;
}
And this code is for changing A to a, z to Z convert small to capital lettor, or reverse.
but when done, i found something wierd cuz whenever i put a char to the program,
it always return both the result that i expected and another "wrong input". and i didnt put anything to my standard input except a charactor and a Enter.
So, here is my question.
The function getchar() or some other like fgetc, fgets recieve a 'enter' as a charactor?