char* clean_string (char *input_string){
/*Ensure that input string isn't null and only do heavy lifting if it's not null*/
if (input_string){
char *stripped;
stripped = (char*)malloc(strlen(input_string)*sizeof(char));
while (*input_string != '\0'){
if isalpha(*input_string){
*stripped = toupper(*input_string);
input_string++;
stripped++;
} else {
input_string++;
}
}
/* *stripped++ += '\0';*/
return stripped;
}
/*default return val*/
return NULL;
}
有人可以告诉我哪里出错了吗?试图做一个测试运行,当我尝试调用它时,它不输出任何内容。从函数中返回一个字符串C
你是什么意思的 “输出” 吗? – littleadv
存储指针被剥离的初始值并返回该指针并取消注释该部分* stripped ++ + ='\ 0'; –
尝试发布可编译代码:'if isalpha(* input_string){'不能编译! –