How to get null terminated pointer of a string in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string s("c++ programming");

	const char *p = s.c_str();

	cout << p << endl;

	return 0;
}

/*
run:

c++ programming

*/

 



answered May 8, 2018 by avibootz

Related questions

1 answer 226 views
226 views asked May 13, 2021 by avibootz
1 answer 216 views
1 answer 202 views
202 views asked May 13, 2021 by avibootz
2 answers 371 views
2 answers 293 views
293 views asked May 5, 2017 by avibootz
...