Connecting Tech Pros Worldwide Help | Site Map

std::string

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 06:00 PM
conf
Guest
 
Posts: n/a
Default std::string

How to know if a std::string has empty content or not? Thanks!



  #2  
Old July 22nd, 2005, 06:00 PM
Siemel Naran
Guest
 
Posts: n/a
Default Re: std::string

"conf" <conf@soft.com> wrote in message
news:TXAUc.220081$OB3.10255@bgtnsc05-
[color=blue]
> How to know if a std::string has empty content or not? Thanks![/color]

bool isempty = string.empty();

or

if (string.empty()) {
...
}

You can also do

if (string.size()) {
...
}


  #3  
Old July 22nd, 2005, 06:00 PM
Sharad Kala
Guest
 
Posts: n/a
Default Re: std::string


"conf" <conf@soft.com> wrote in message
news:TXAUc.220081$OB3.10255@bgtnsc05-news.ops.worldnet.att.net...[color=blue]
> How to know if a std::string has empty content or not? Thanks![/color]

std::string has an empty member function to check for empti-ness.
if (s.empty())
{
//...
}

-Sharad


  #4  
Old July 22nd, 2005, 06:00 PM
Siemel Naran
Guest
 
Posts: n/a
Default Re: std::string

"Sharad Kala" <no__spam.sharadk_ind@yahoo.com> wrote in message
[color=blue]
> std::string has an empty member function to check for empti-ness.
> if (s.empty())[/color]

I was thinking, the name is a bit unfortunate. It's a verb, so indicates
that it will empty out 's'. I think s.isempty() would have been nicer :).


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.