search

Home  >  Q&A  >  body text

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

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

高洛峰高洛峰2882 days ago1620

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 11:32:12

    The error message is obvious, there is no such function.

    It is said that there is no such function as toupper(string) in C++, and there is no such function as toupper(char *) in C. You can only use toupper(char) character by character.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:32:12

    The error I see here is

    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/
    From this document, it seems that toupper should be the C function, but it accepts int, and the questioner passed string, so it is not match.

    reply
    0
  • Cancelreply