Why use c strings in c++?

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

    Textbooks feature old-school C strings because many basic functions still expect them as arguments, or return them. Additionally, it gives some insight into the underlying structure of the string in memory.

提交回复
热议问题