C++去除字符串中的空格

#include <cstring>
#include <iostream>
using namespace std;
 
 
int  main()
{
    char TstArr[] = "12  34 56 kskks ututi ss 1129 288";
    cout << TstArr <<endl;
 
 
    char *pCur = TstArr;
    char *pBlank = pCur;
 
 
        while(*pCur != '\0')//need change with the array
        {
 
 
                if(*pCur != ' ')
                {
                    *pBlank = *pCur;
                    pBlank ++;
                    pCur ++;
                }
                else
                {
                    pCur ++;
                }
 
 
 
 
        }
 
 
    
    *pBlank = *pCur;
    cout<< TstArr;
 
 
    return 1;
}
发布了12 篇原创文章 · 获赞 6 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/huaweizte123/article/details/53897803
今日推荐