Why use c strings in c++?

后端 未结 18 2147
终归单人心
终归单人心 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:37

    Legacy code that doesn't know of std::string. Also, before C++11 opening files with std::ifstream or std::ofstream was only possible with const char* as an input to the file name.

提交回复
热议问题