去掉字符串中的“:”

#include <iostream>

#include <string>

#include <Windows.h>

#include <fstream>

#include <sstream>

#include <signal.h>

#include <io.h>

#include <vector>

#include <process.h>

#include <cstdio> 

 

 

//------------去掉":"-----------------------

int m = 0, j;

while (readbuf[m] != '\0') //遍历所有字符

{

if (readbuf[m] == ':') //如果是冒号

{

j = m;

while (readbuf[j] != '\0') //则把冒号之后的所有字符往前移一位

{

readbuf[j] = readbuf[j + 1];

j++;

}

continue;//因为冒号被后一个覆盖,所以i先不自增,以判断覆盖它的是不是冒号。

}

m++;

}

cout << readbuf << endl;

system("pause");

}

return 0;

}

posted @ 2021-06-24 08:13  江南王小帅  阅读(395)  评论(0)    收藏  举报