Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Dec 9, 1998

Clearing the Contents of a String

To explicitly erase the contents of a string object, you can use the member function erase():
 
void f(){
  char key;
  string msg = "press any key to continue";
  cout<<msg<<endl;
  cin<<key;
  msg.erase(); //clear msg
}
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date