如何在字符串(char数组)中查找元素并将其加倍?

问题描述:

我需要: - 输入字符串
- 找到该字符串元素“>”
-double it。如何在字符串(char数组)中查找元素并将其加倍?

举例: 开关输入:123> 21 输出:123 >> 21

只要使用字符串::查找和字符串::插入。

const char *c_str = "123>45"; 
std::string a = std::string(c_str); 
std::string b = ">"; 
a.insert(a.find(b), b); 
c_str = a.c_str();