本帖最后由 .Drenched 于 2014-4-24 02:36 编辑
- int main (int argc, char *argv[])
- {
- if (argc != 4) {
- std::cerr << "wrong" << std::endl;
- return -1;
- }
- std::string str1 (argv[1]), str2 (argv[2]), str3 (argv[3]);
- std::string::iterator match_begin
- = std::search (str1.begin(), str1.end(), str2.begin (), str2.end ());
- if (match_begin == str1.end ()) {
- std::cerr << "wrong" << std::endl;
- return -1;
- }
- std::string::iterator match_end = match_begin + str2.size ();
- std::string result (str1.begin (), match_begin);
- result.append (str3.begin(), str3.end ());
- result.append (match_end, str1.end ());
- std::cout << result << std::endl;
- return 0;
- }
复制代码 这样写编译报错,为什么。
|