c++ std::string, .data()

c++ std::string is a class, its object can be used to store text.

It has a method .data() to return the underlying raw string.

#include <iostream>
#include <string>

int main()
{
	std::string str = "Hello, the world!";
	std::cout << str << std::endl;
	const char * raw = str.data();
	std::cout << raw << std::endl;
}

Index

Home