By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,852 Members | 2,219 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,852 IT Pros & Developers. It's quick & easy.

std::string

P: n/a
How to know if a std::string has empty content or not? Thanks!
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


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


bool isempty = string.empty();

or

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

You can also do

if (string.size()) {
...
}
Jul 22 '05 #2

P: n/a

"conf" <co**@soft.com> wrote in message
news:TX********************@bgtnsc05-news.ops.worldnet.att.net...
How to know if a std::string has empty content or not? Thanks!


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

-Sharad
Jul 22 '05 #3

P: n/a
"Sharad Kala" <no******************@yahoo.com> wrote in message
std::string has an empty member function to check for empti-ness.
if (s.empty())


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 :).
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.