记录详情

Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:59:11: error: conflicting declaration 'char s1 [10000]'
  char s1[N];
           ^
/in/foo.cc:58:6: note: previous declaration as 'int s1 [10000]'
  int s1[N],s2[N];
      ^~
/in/foo.cc:60:11: error: conflicting declaration 'char s2 [10000]'
  char s2[N];
           ^
/in/foo.cc:58:12: note: previous declaration as 'int s2 [10000]'
  int s1[N],s2[N];
            ^~
/in/foo.cc:61:23: error: no matching function for call to 'std::basic_istream<char>::getline(int [10000], int)'
  std::cin.getline(s1,N);
                       ^
In file included from /usr/include/c++/6/iostream:40:0,
                 from /in/foo.cc:1:
/usr/include/c++/6/istream:647:5: note: candidate: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(std::basic_istream<_CharT, _Traits>::char_type*, std::streamsize, std::basic_istream<_CharT, _Traits>::char_type) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::char_type = char; std::streamsize = long int]
     basic_istream<char>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/istream:647:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/6/istream:427:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(std::basic_istream<_CharT, _Traits>::char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::char_type = char; std::streamsize = long int]
       getline(char_type* __s, streamsize __n)
       ^~~~~~~
/usr/include/c++/6/istream:427:7: note:   no known conversion for argument 1 from 'int [10000]' to 'std::basic_istream<char>::char_type* {aka char*}'
/in/foo.cc:62:9: error: cannot convert 'int*' to 'const char*' for argument '1' to 'int puts(const char*)'
  puts(s1);
         ^
/in/foo.cc:58:12: warning: unused variable 's2' [-Wunused-variable]
  int s1[N],s2[N];
            ^~

信息

递交者
类型
自测
题目
A8-4 字符串的连接函数
语言
C++
递交时间
2024-12-02 13:50:56
评测时间
2024-12-02 13:50:56
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes