记录详情

Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:58:9: error: 's2' was not declared in this scope
  int s1;s2;
         ^~
/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'
  int s1;s2;
      ^~
/in/foo.cc:61:23: error: invalid conversion from 'int' to 'std::basic_istream<char>::char_type* {aka char*}' [-fpermissive]
  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:427:7: note:   initializing argument 1 of '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)
       ^~~~~~~
/in/foo.cc:62:9: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
  puts(s1);
         ^
In file included from /usr/include/c++/6/cstdio:42:0,
                 from /usr/include/c++/6/ext/string_conversions.h:43,
                 from /usr/include/c++/6/bits/basic_string.h:5417,
                 from /usr/include/c++/6/string:52,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from /in/foo.cc:1:
/usr/include/stdio.h:697:12: note:   initializing argument 1 of 'int puts(const char*)'
 extern int puts (const char *__s);
            ^~~~

信息

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