What is use of c_str function In c++

前端 未结 7 1251
忘了有多久
忘了有多久 2020-12-04 06:30

I have just started reading C++ and found c++ having rich functions for string manipulation which C does not have. I am reading these function and came across c_str()<

7条回答
  •  星月不相逢
    2020-12-04 06:39

    c_str() converts a C++ string into a C-style string which is essentially a null terminated array of bytes. You use it when you want to pass a C++ string into a function that expects a C-style string (e.g. a lot of the Win32 API, POSIX style functions, etc).

提交回复
热议问题