Language: C++

#include <iostream>
using namespace std;

int main() {
    string s;
    int k;
    int tmp;
    cin >> s >> tmp;
    k = tmp - 1;
    int point = 0;
    char def;
    bool getsuccess = false;
    for (int i = 0; i < s.length - 1; ++i){
        if (s[i] != '1') {
            point = i;
            def = s[i];
            getsuccess = true;
            break;
        }
    }
    if (!getsuccess && s[s.length - 1] == '1') {
        point = s.length;
    } 
    else if (!getsuccess && s[s.length - 1] != '1') {
        point = s.length - 1;
        def = s[s.length - 1];
    }
    if (point <= k) {
        cout << def;
    }
    else {
        cout << 1;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   13 |     for (int i = 0; i < s.length - 1; ++i){
      |                         ~~^~~~~~
      |                                 ()
a.cc:21:28: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   21 |     if (!getsuccess && s[s.length - 1] == '1') {
      |                          ~~^~~~~~
      |                                  ()
a.cc:22:19: error: cannot convert 'std::__cxx11::basic_string<char>::length' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
   22 |         point = s.length;
      |                   ^~~~~~
a.cc:24:33: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   24 |     else if (!getsuccess && s[s.length - 1] != '1') {
      |                               ~~^~~~~~
      |                                       ()
a.cc:25:19: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   25 |         point = s.length - 1;
      |                 ~~^~~~~~
      |                         ()
a.cc:26:19: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   26 |         def = s[s.length - 1];
      |                 ~~^~~~~~
      |                         ()