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

1 answer 205 views
205 views asked Dec 9, 2020 by avibootz
3 answers 676 views
2 answers 273 views
2 answers 111 views
1 answer 107 views
107 views asked Jul 9, 2024 by avibootz
...