Inconsistency between std::string and string literals

后端 未结 6 1468
耶瑟儿~
耶瑟儿~ 2020-12-28 12:30

I have discovered a disturbing inconsistency between std::string and string literals in C++0x:

#include 
#include          


        
6条回答
  •  星月不相逢
    2020-12-28 13:20

    If you wanted the length, you should use strlen() for the C string and .length() for the C++ string. You can't treat C strings and C++ strings identically--they have different behavior.

提交回复
热议问题