解析字符串和交换子 [英] Parse string and swap substrings
问题描述
我如何可以解析由用户和交换旧子与新字符串的所有实例给出的字符串。我有一个功能的工作,但我真的不确定,当谈到字符串。
无效spliceSwap(字符* inputStr,为const char * oldStr,为const char *中newstr)
最简单的解决方法是使用谷歌(<一个href=\"http://stackoverflow.com/questions/1494399/how-do-i-search-find-and-replace-in-a-standard-string\">First链接)在这里。另外要注意,在C ++中,我们preFER 的std ::字符串
在为const char *
。不要写你自己的的std ::字符串
,使用的内置之一。您code似乎更加的 C 比C ++!
How can I parse a string given by a user and swap all occurrences of the old substring with the new string. I have a function to work with but I am really uncertain when it comes to strings.
void spliceSwap( char* inputStr, const char* oldStr, const char* newStr )
The simplest solution is to use google (First link) here. Also be aware that in C++ we prefer std::string
over const char *
. Do not write your own std::string
, use the built-in one. Your code seems to be more C than C++!
这篇关于解析字符串和交换子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!