fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main() {
  5. string s,s0;
  6. char c;
  7. cout<<"Введите строки";
  8. getline(cin,s);
  9. getline(cin,s0);
  10. cout<<"Введите символ";
  11. cin>>c;
  12. for(unsigned int i=0;i<s.length();i++)
  13. {if(s[i]==c) s.insert(s0,i-1);}
  14. cout<<s;
  15. return 0;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13:30: error: no matching function for call to 'std::basic_string<char>::insert(std::string&, unsigned int)'
  {if(s[i]==c) s.insert(s0,i-1);}
                              ^
prog.cpp:13:30: note: candidates are:
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:1203:7: note: void std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; typename _Alloc::rebind<_CharT>::other::pointer = char*; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       insert(iterator __p, size_type __n, _CharT __c)
       ^
/usr/include/c++/4.9/bits/basic_string.h:1203:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/4.9/bits/basic_string.h:1220:9: note: template<class _InputIterator> void std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
         insert(iterator __p, _InputIterator __beg, _InputIterator __end)
         ^
/usr/include/c++/4.9/bits/basic_string.h:1220:9: note:   template argument deduction/substitution failed:
prog.cpp:13:30: note:   cannot convert 's0' (type 'std::string {aka std::basic_string<char>}') to type 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}'
  {if(s[i]==c) s.insert(s0,i-1);}
                              ^
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:1251:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       insert(size_type __pos1, const basic_string& __str)
       ^
/usr/include/c++/4.9/bits/basic_string.h:1251:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::basic_string<char>::size_type {aka unsigned int}'
/usr/include/c++/4.9/bits/basic_string.h:1273:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       insert(size_type __pos1, const basic_string& __str,
       ^
/usr/include/c++/4.9/bits/basic_string.h:1273:7: note:   candidate expects 4 arguments, 2 provided
In file included from /usr/include/c++/4.9/string:53:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.tcc:359:6: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
      basic_string<_CharT, _Traits, _Alloc>::
      ^
/usr/include/c++/4.9/bits/basic_string.tcc:359:6: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/4.9/string:52:0,
                 from /usr/include/c++/4.9/bits/locale_classes.h:40,
                 from /usr/include/c++/4.9/bits/ios_base.h:41,
                 from /usr/include/c++/4.9/ios:42,
                 from /usr/include/c++/4.9/ostream:38,
                 from /usr/include/c++/4.9/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.9/bits/basic_string.h:1314:7: note: 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>::size_type = unsigned int]
       insert(size_type __pos, const _CharT* __s)
       ^
/usr/include/c++/4.9/bits/basic_string.h:1314:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::basic_string<char>::size_type {aka unsigned int}'
/usr/include/c++/4.9/bits/basic_string.h:1337:7: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       insert(size_type __pos, size_type __n, _CharT __c)
       ^
/usr/include/c++/4.9/bits/basic_string.h:1337:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/4.9/bits/basic_string.h:1355:7: note: std::basic_string<_CharT, _Traits, _Alloc>::iterator std::basic_string<_CharT, _Traits, _Alloc>::insert(std::basic_string<_CharT, _Traits, _Alloc>::iterator, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::iterator = __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >; typename _Alloc::rebind<_CharT>::other::pointer = char*]
       insert(iterator __p, _CharT __c)
       ^
/usr/include/c++/4.9/bits/basic_string.h:1355:7: note:   no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'std::basic_string<char>::iterator {aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}'
stdout
Standard output is empty