當前位置:編程學習大全網 - 電腦編程 - C++編程:從鍵盤上輸入壹個字符串,編寫程序,刪除該字符串中的指定的字符

C++編程:從鍵盤上輸入壹個字符串,編寫程序,刪除該字符串中的指定的字符

string funstr(string is_str, string ls_str_a) //is_str:輸入的字符串;ls_str_a:要被替換的小字符串;返回值:替輸出的字符串

{

string ls_str_out = is_str;

int pos = is_str.find(ls_str_a);

if (pos != string::npos)

{

ls_str_out= is_str.replace(pos, ls_str_a.length(), "");

//pos表示要替換起始位置,ls_str_a.length()表示要替換的長度,""表示要替換成空

}

return ls_str_out;

}

  • 上一篇:labview編程修改選中文字的字體
  • 下一篇:妳是如何把九個橘子分成五個的?
  • copyright 2024編程學習大全網