Compile Error

foo.cc: In function 'int main()':
foo.cc:6:16: error: no matching function for call to 'getline(std::istream&, int&)'
    6 |  getline(cin,s1);
      |                ^
In file included from /usr/include/stdio.h:864,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:46,
                 from foo.cc:1:
/usr/include/x86_64-linux-gnu/bits/stdio.h:118:1: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)'
  118 | getline (char **__lineptr, size_t *__n, FILE *__stream)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/bits/stdio.h:118:1: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.tcc:1538:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 1538 |     getline(basic_istream<_CharT, _Traits>& __in,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1538:5: note:   template argument deduction/substitution failed:
foo.cc:6:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    6 |  getline(cin,s1);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6456:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6456 |     getline(basic_istream<_CharT, _Traits>& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6456:5: note:   template argument deduction/substitution failed:
foo.cc:6:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    6 |  getline(cin,s1);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6464:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 6464 |     getline(basic_istream<_CharT, _Traits>&& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6464:5: note:   template argument deduction/substitution failed:
foo.cc:6:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    6 |  getline(cin,s1);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6471:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6471 |     getline(basic_istream<_CharT, _Traits>&& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6471:5: note:   template argument deduction/substitution failed:
foo.cc:6:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    6 |  getline(cin,s1);
      |                ^
foo.cc:7:16: error: no matching function for call to 'getline(std::istream&, int&)'
    7 |  getline(cin,s2);
      |                ^
In file included from /usr/include/stdio.h:864,
                 from /usr/include/c++/9/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:46,
                 from foo.cc:1:
/usr/include/x86_64-linux-gnu/bits/stdio.h:118:1: note: candidate: '__ssize_t getline(char**, size_t*, FILE*)'
  118 | getline (char **__lineptr, size_t *__n, FILE *__stream)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/bits/stdio.h:118:1: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/9/string:56,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.tcc:1538:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 1538 |     getline(basic_istream<_CharT, _Traits>& __in,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.tcc:1538:5: note:   template argument deduction/substitution failed:
foo.cc:7:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    7 |  getline(cin,s2);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6456:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6456 |     getline(basic_istream<_CharT, _Traits>& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6456:5: note:   template argument deduction/substitution failed:
foo.cc:7:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    7 |  getline(cin,s2);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6464:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, _CharT)'
 6464 |     getline(basic_istream<_CharT, _Traits>&& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6464:5: note:   template argument deduction/substitution failed:
foo.cc:7:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    7 |  getline(cin,s2);
      |                ^
In file included from /usr/include/c++/9/string:55,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from foo.cc:1:
/usr/include/c++/9/bits/basic_string.h:6471:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::getline(std::basic_istream<_CharT, _Traits>&&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&)'
 6471 |     getline(basic_istream<_CharT, _Traits>&& __is,
      |     ^~~~~~~
/usr/include/c++/9/bits/basic_string.h:6471:5: note:   template argument deduction/substitution failed:
foo.cc:7:16: note:   mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' and 'int'
    7 |  getline(cin,s2);
      |                ^
foo.cc:8:19: error: request for member 'size' in 's1', which is of non-class type 'int'
    8 |  for(int i=0;i<s1.size();i++)
      |                   ^~~~
foo.cc:9:10: error: invalid types 'int[int]' for array subscript
    9 |   if(s1[i]>='a'&&s1[i]<='z')
      |          ^
foo.cc:9:22: error: invalid types 'int[int]' for array subscript
    9 |   if(s1[i]>='a'&&s1[i]<='z')
      |                      ^
foo.cc:11:19: error: request for member 'size' in 's2', which is of non-class type 'int'
   11 |  for(int i=0;i<s2.size();i++)
      |                   ^~~~
foo.cc:12:10: error: invalid types 'int[int]' for array subscript
   12 |   if(s2[i]>='a'&&s2[i]<='z')
      |          ^
foo.cc:12:22: error: invalid types 'int[int]' for array subscript
   12 |   if(s2[i]>='a'&&s2[i]<='z')
      |                      ^
[Hydro](https://hydro.ac)提供评测服务

信息

递交者
类型
自测
题目
P1077 A8-2 字符串的统计函数
语言
C++
递交时间
2022-02-13 16:25:35
评测时间
2022-02-13 16:25:35
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes