引用 | 編輯
ety
2007-06-07 19:24 |
2樓
▲ ▼ |
字串的輸出是不是只許可字母與空白? 其它符號都忽略? 數字是否輸出?
你只要判斷其 ASCII 是否在 65~90 與 97~122 這兩個區間就好了, 是就輸出, 不是就忽略, 空白鍵好像是 32, 我也不太清楚, 你可以再查證! x0 |
引用 | 編輯
jim28791
2007-06-07 21:03 |
3樓
▲ |
拍謝~~我說明不清楚~~
我後來想到... 可以這樣用~~ #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { char str[]= "I $%am 5a%$ good#@$ student"; int i; printf("字串轉換前%s\n",str); printf("字串轉換後\n"); for(i=0;i<strlen(str);i++) if(isalpha((str)) !=0 ) printf("%c",str); else printf(" "); return 0; } x0 |