1个回答
展开全部
#include <iostream>
using namespace std;
int main()
{
char c[]= "this is a test character string";
char *p = c;
char *t = NULL;
while(*p != '\0')
{
if (*p == ' ')
{
//空格以后的所有字符串前移一个位置
t = p;
while(*t != '\0')
{
*t = *(t+1);
t++;
}
}
p++;
}
p = c;
while(*p != '\0')
{
cout << *p++;
}
cout << endl;
return 0;
}
using namespace std;
int main()
{
char c[]= "this is a test character string";
char *p = c;
char *t = NULL;
while(*p != '\0')
{
if (*p == ' ')
{
//空格以后的所有字符串前移一个位置
t = p;
while(*t != '\0')
{
*t = *(t+1);
t++;
}
}
p++;
}
p = c;
while(*p != '\0')
{
cout << *p++;
}
cout << endl;
return 0;
}
追问
while(*p != '\0')
{
cout << *p++;
}
cout << endl;
这里好像有点问题,cout没有说明。。。我有点看不懂
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询