>  Q&A  >  본문

[C++ Error] no matching function for call to 'toupper(__gnu_cxx::__alloc_traits<std::allocator<std::basic_string<char> > >::value_type&)'

菜鸟一名,求助,百度了这段错误提示,可是没找到答案。请说简单一点,刚学c++没多久。谢谢

高洛峰高洛峰2713일 전1351

모든 응답(2)나는 대답할 것이다

  • ringa_lee

    ringa_lee2017-04-17 11:32:12

    错误信息很明显,没这个函数。

    话说C++里本来就没有toupper(string)这么个函数,C里也没有toupper(char *)这么个函数。你只能一个字符一个字符的用toupper(char)。

    회신하다
    0
  • ringa_lee

    ringa_lee2017-04-17 11:32:12

    我这里看到的错误是

    toupper.cc: In function ‘int main()’:
    toupper.cc:17: error: cannot convert ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’ to ‘int’ for argument ‘1’ to ‘int toupper(int)’
    

    http://www.cplusplus.com/reference/cctype/toupper/
    从这篇文档看来,toupper应该是C函数,只不过它接受的是int,题主传的是string,所以not match了。

    회신하다
    0
  • 취소회신하다