• c++ string c_str() 和data()区别


      看下面的英文解释:

    const char* c_str ( ) const;
    Get C string equivalent
    Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters.
    A terminating null character is automatically appended.

    const char* data() const;
    Get string data
    Returns a pointer to an array of characters with the same content as the string.
    Notice that no terminating null character is appended (see member c_str for such a functionality).

    c_str()字符串后有'\0',而data()没有。

     

  • 相关阅读:
    Servlet Class4
    Servlet Class3
    Servlet Class2
    Servlet Class1
    HTTP基础知识
    XML基础知识
    JAVA Class25
    JAVA Class24
    JAVA Class23
    JAVA Class22
  • 原文地址:https://www.cnblogs.com/youxin/p/2546883.html
Copyright © 2020-2023  润新知