Why use c strings in c++?

后端 未结 18 2169
终归单人心
终归单人心 2021-02-07 04:12

Is there any good reason to use C-strings in C++ nowadays? My textbook uses them in examples at some points, and I really feel like it would be easier just to use a std::string

18条回答
  •  花落未央
    2021-02-07 04:22

    STL strings are certainly far easier to use, and I don't see any reason to not use them.

    If you need to interact with a library that only takes C-style strings as arguments, you can always call the c_str() method of the string class.

提交回复
热议问题