How to clear a string (deletes all character from 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++");

	s.clear();

	cout << s << endl;

	return 0;
}

/*
run:



*/

 



answered May 8, 2018 by avibootz

Related questions

...