#include
// 从src删除知道字符ch,存到dst并返回
char *strRemov(char* dst, const char* src, char ch = ' ')
{
int i = -1, j = 0;
while (src[++i])
if (src[i] != ch)
dst[j++] = src[i];
dst[j] = '\0';
return dst;
}
int main()
{
char a[100] = "this is a test!", b[100];
puts(strRemov(b, a));
return 0;
}
string catsting(string Srcstr)
{
string dststr;
size_t posstion = 0;
while(Srcstr.size() != 0)
{
if(string::npos != Srcstr.find_first_of(" "))
{
posstion = Srcstr.find_first_of(" ");
string tmpstr (Srcstr,0,posstion);
dststr += tmpstr;
Srcstr =Srcstr.erase(0,posstion+1 );
}
else
break;
}
dststr += Srcstr;
return dststr;
}
调试通过的!
string f(string str)
{
string return_str="";
int length=str.length();
for(int i=0;i
return return_str;
}
void f(char s1[],char s2[])
{
int i=0,j=0;
for(i=0;s2[i]!=0;i++)
{
if(s2[i]==' ')
{
i++;
}
else
{
s1[j]=s2[i];
j++;
}
}
s1[j]=0;
}