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 233 views
233 views asked May 13, 2021 by avibootz
1 answer 221 views
1 answer 209 views
209 views asked May 13, 2021 by avibootz
2 answers 379 views
2 answers 305 views
305 views asked May 5, 2017 by avibootz
...