string c_str() in C++

c_str(): It returns const pointer to null-terminated contents. 

This is a handle to internal data. 

Parameter: No parameter required.

Syntax:

str.c_str()

For Example:

str =""

str.c_str()

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str = "";
    cout << *str.c_str() << "\n";

    return 0;
}


No comments:

Post a Comment