Translations of this page?:

data

Syntax:

    #include <string>
    const char *data() const;

data()関数は、現在の文字列の先頭文字を指すポインタを返します。

例:

#include <iostream>
#include <string>
using namespace std;
 
int main ()
{
    string str1="hello";
    const char *ch;
    size_t n=str1.length();
    ch=str1.data();
    for(int i=0;i<=n;i++)
    {
        cout<<*(ch++);
    }
    return 0;
}

Related Topics: String_operators, c_str

 
• • • SitemapRecent changesRSScc