想知道如何获取字符串并删除特殊字符,使所有字符小写,但保留空格不变。
示例:
这:“世界你好!你好吗?”
会是这样的: Hello World ,你好吗
最佳答案
尝试使用 isalpha() 函数,如下所示:
void removeSpecialCharacter(char *str) {
int source = 0;
int destination = 0;
while (str[source] != '\0') {
if (isalpha(str[source])) {
str[destination] = str[source];
++destination;
}
++source; }
str[destination] = '\0';
}
关于c - C语言中如何删除字符串中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29699804/