使用while(x!='/n')时,/n还是被算进去怎么办

题目为:键盘连续输入字符,回车结束。如果输入的是英文字符,则大小写互换;不是英文字符则输出。比如输入aZ8Bx+,则输出AzbX*

#include <stdio.h>
#include <math.h>
int main()
{
    char x,c;
    do 
    {
        scanf("%c",&x);
        if( x <= 'Z' && x >= 'A' )
        {
            c = x + 32;
            printf("%c",c);
        }
        else if( x <= 'z' && x >= 'a' )
        {
            c = x - 32;
            printf("%c",c);
        }
        else printf("*");
     }while( x != '\n'); 

    return 0;
}


输出结果为:
/shudb465sda
SHUDB
*SDA


Process exited after 5.152 seconds with return value 0
请按任意键继续. . .
/
前面对应的上,但是最后都会多出一个
星号 这种情况请问应该怎么解决?

你应该一输入就对x是否是'\n'进行判断