38行的编译失败信息?

回复帖子 返回题目

@ huangzirui 2017-08-13 17:31

如下

#include<stdio.h>
#include<algorithm>
#include<string.h>
char a[21][1000];
int i,s,n,j;
int cmp(char *c,char *b){
    char n[1000],m[1000];
    strcpy(n,c);
    strcat(n,b);
    strcpy(m,b);
    strcat(m,c);
    return strcmp(m,n);
}
int main()
{   scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%s",a[i]);
    std::sort(a[i],a[j],cmp);
    for(i=1;i<=n;i++)
        printf("%s",a[i]);
    return 0;
}
@ huangzirui 2017-08-13 17:31 回复

In file included from /tmp/runtime/include/c++/4.9.4/bits/stl_algobase.h:71:0,

from /tmp/runtime/include/c++/4.9.4/algorithm:61,

from /tmp/tmpCWLHHn.cpp:2:

/tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = char*; _Iterator2 = char*; _Compare = int (*)(char*, char*)]':

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1846:27: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1884:70: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1970:55: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:4717:78: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = char*; _Compare = int (*)(char*, char*)]'

/tmp/tmpCWLHHn.cpp:18:28: required from here

/tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h:121:46: error: invalid conversion from 'char' to 'char*' [-fpermissive]

{ return bool(_M_comp(*__it1, *__it2)); }

^ /tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h:121:46: error: invalid conversion from 'char' to 'char*' [-fpermissive]

/tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = char; _Iterator = char*; _Compare = int (*)(char*, char*)]':

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1827:34: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Val_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1855:46: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1884:70: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1970:55: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:4717:78: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = char*; _Compare = int (*)(char*, char*)]'

/tmp/tmpCWLHHn.cpp:18:28: required from here

/tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h:166:37: error: invalid conversion from 'char' to 'char*' [-fpermissive]

{ return bool(_M_comp(__val, *__it)); }

^ /tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h:166:37: error: invalid conversion from 'char' to 'char*' [-fpermissive]

/tmp/runtime/include/c++/4.9.4/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = char*; _Value = char; _Compare = int (*)(char*, char*)]':

/tmp/runtime/include/c++/4.9.4/bits/stl_heap.h:129:76: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = char*; _Distance = long int; _Tp = char; _Compare = __gnu_cxx::__ops::_Iter_comp_val<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_heap.h:230:51: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = char*; _Distance = long int; _Tp = char; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_heap.h:334:15: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1673:49: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, ch…

@ xun薰 2017-08-13 17:35 回复

sort排序不应该这样写吧...

如果你要排序的话

a+1,a+strlen(a)+1,cmp

@ Broadway 2017-08-13 18:49 回复

C++就是这么 恶心 ……

有的时候编译信息又多又复杂还看不懂…………

@ 神罗天征 2017-08-16 20:35 回复

In file included from /tmp/runtime/include/c++/4.9.4/bits/stl_pair.h:59:0,

from /tmp/runtime/include/c++/4.9.4/utility:70,

from /tmp/runtime/include/c++/4.9.4/algorithm:60,

from /tmp/tmpfGpf1j.cpp:2:

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]':

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1884:70: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1970:55: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:4717:78: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = char (*)[1000]; _Compare = int (*)(char*, char*)]'

/tmp/tmpfGpf1j.cpp:18:28: required from here

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1849:11: error: array must be initialized with a brace-enclosed initializer

__val = _GLIBCXX_MOVE(*__i);

^ In file included from /tmp/runtime/include/c++/4.9.4/algorithm:62:0,

from /tmp/tmpfGpf1j.cpp:2:

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1851:17: error: invalid array assignment

*__first = _GLIBCXX_MOVE(__val);

^ In file included from /tmp/runtime/include/c++/4.9.4/bits/stl_pair.h:59:0,

from /tmp/runtime/include/c++/4.9.4/utility:70,

from /tmp/runtime/include/c++/4.9.4/algorithm:60,

from /tmp/tmpfGpf1j.cpp:2:

/tmp/runtime/include/c++/4.9.4/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]':

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1673:49: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1932:59: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1947:59: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1969:11: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:4717:78: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = char (*)[1000]; _Compare = int (*)(char*, char*)]'

/tmp/tmpfGpf1j.cpp:18:28: required from here

/tmp/runtime/include/c++/4.9.4/bits/stl_heap.h:332:25: error: array must be initialized with a brace-enclosed initializer

_ValueType __value = _GLIBCXX_MOVE(*(__first + __parent));

^ /tmp/runtime/include/c++/4.9.4/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]':

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1676:50: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1932:59: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++/4.9.4/bits/stl_algo.h:1947:59: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = char (*)[1000]; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int (*)(char*, char*)>]'

/tmp/runtime/include/c++…