C |字符串|问题12

以下程序的输出

null

#include <stdio.h>
int fun( char *p)
{
if (p == NULL || *p == ' ' ) return 0;
int current = 1, i = 1;
while (*(p+current))
{
if (p[current] != p[current-1])
{
p[i] = p[current];
i++;
}
current++;
}
*(p+i)= ' ' ;
return i;
}
int main()
{
char str[] = "geeksskeeg" ;
fun(str);
puts (str);
return 0;
}


(A) 壁炉 (B) 极客 (C) 极客 (D) 垃圾值 答复: (A) 说明: 该函数主要将一个字符的多次连续出现替换为一次出现。 这个问题的小测验

© 版权声明
THE END
喜欢就支持一下吧
点赞12 分享