日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

C++ 在字符串中插入子串+推断字符串是否由空格组成

發布時間:2025/4/14 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C++ 在字符串中插入子串+推断字符串是否由空格组成 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
// Example3.cpp : 定義控制臺應用程序的入口點。

#include "StdAfx.h" #include <string> #include <iostream> using namespace std; int main(void) { string str,str1,str2; int index; //推斷截取的子串是否由blanks組成 str=" cjc is a master."; str1="cjc is a master."; index=str.find("cjc"); str.assign(str.c_str(),index); if(str.find_first_not_of(" ")==-1) { cout<<"The string is constructed of blanks..."<<endl; } else { cout<<str<<endl; } //在字符串中插入子串 index=str1.find("master"); str2=str1.substr(index); str1.assign(str1.c_str(),index); str=str1+"good "+str2; cout<<str<<endl; system("pause"); return 0; }


轉載于:https://www.cnblogs.com/lytwajue/p/7363422.html

總結

以上是生活随笔為你收集整理的C++ 在字符串中插入子串+推断字符串是否由空格组成的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。