C ++在位置4插入1个字母怎么做
我有一个字符串
欧元兑美元
我如何将其转换为欧元/美元
我尝试了类似的东西
string result;
result = "EURUSD";
result.insert(3,"/");
它不起作用。
main.cpp:202:24: error: passing ‘const string {aka const std::basic_string<char>}’ as ‘this’ argument of ‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>, std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>, std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]’ discards qualifiers [-fpermissive]
main.cpp:203:2: error: expected ‘;’ before ‘cout’