★P〓P★的随笔

纸上得来终觉浅,绝知此事要躬行。

c_str() 函数

Syntax:
  #include <string>

  const char* c_str();

 

The function c_str() returns a const pointer to a regular C string, identical to the current string. The returned string is null-terminated.

Note that since the returned pointer is of type const, the character data that c_str() returns cannot be modified. Furthermore, you do not need to call free() or delete on this pointer.


c_str函数的返回值是const char*的,不能直接赋值給char*。

c_str()返回一个客户程序可读不可改的指向字符数组的指针,不需要手动释放或删除这个指针。

posted on 2008-08-21 09:50  itolssy  阅读(1719)  评论(0编辑  收藏  举报

导航