Language: C++

#include<iostream>
#include<string>
#include<cctype>
using namespace std;

string reverse(string s,int n,int m){
    string t =s.substr(n,m);
    string u;
    for (int i = 0; i < t.size()-1; i++){
        u[i] = t[t.size()-1-i];
    }
    return s.replace(n,m,u);
}

int main(){
    string word,ord;
    int a,b,c;
    cin >> word >> a;
    for(int i = 0; i < n; i++){
        cin >> ord >> b >> c;
        if (ord == "print") cout << word.substr(b,c) << endl;
        else if (ord == "reverse") {
            word = word.replace(b,c);
            cout >> word >> endl;
        }
        else{
            string d;
            cin >> d;
            word = word.replace(b,c,d);
            cout >> word >> endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:24: error: 'n' was not declared in this scope
   19 |     for(int i = 0; i < n; i++){
      |                        ^
a.cc:23:32: error: no matching function for call to 'std::__cxx11::basic_string<char>::replace(int&, int&)'
   23 |             word = word.replace(b,c);
      |                    ~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:2413:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2413 |         replace(const_iterator __i1, const_iterator __i2,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2413:9: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2522:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2540:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2540 |         replace(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2562:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2562 |         replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2562:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2200:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2200:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2223:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2223 |       replace(size_type __pos1, size_type __n1, const basic_string& __str,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note:   candidate expects 5 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2249:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2249 |       replace(size_type __pos, size_type __n1, const _CharT* __s,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2249:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2275:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2275:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2300:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2300 |       replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2300:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2319:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2319:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2340:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 2340 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2340:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2363:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2363 |       replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2363:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2385:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 2385 |       replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2385:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2444:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, _CharT*, _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2444 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2444:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2456:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2456 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2456:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2468:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, iterator, iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; iterator = std::__cxx11::basic_string<char>::iterator]'
 2468 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2468:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2480:7: note: candidat