原代碼錯誤點
if (c = ' ') // 錯誤1:賦值而非比較
if ('A' <= c <= 'Z') // 錯誤2:鏈式比較無效,實為 ('A'<=c) 結果(0/1) <= 'Z' 恆真
if (0 <= c <= 9) // 錯誤3:字符比較數字字面量,應比較字符 '0' '9'
修正代碼
if (c == ' ') // 比較
if (c >= 'A' && c <= 'Z') // 邏輯與
if (c >= 'a' && c <= 'z')
if (c >= '0' && c <= '9') // 字符比較
完整修正版
int main() {
char c;
printf("輸入字符:");
scanf("%c", &c);
if (c == ' ') printf("空格");
else if (c >= 'A' && c <= 'Z') printf("大寫字母");
else if (c >= 'a' && c <= 'z') printf("小寫字母");
else if (c >= '0' && c <= '9') printf("數字");
else printf("其他字符");
system("pause");
return 0;
}