empty
Syntax:
#include <string> bool empty() const;
The empty() function returns true if the string has no elements, false otherwise.
For example:
string s1;
string s2("");
string s3("This is a string");
cout.setf(ios::boolalpha);
cout << s1.empty() << endl;
cout << s2.empty() << endl;
cout << s3.empty() << endl;
When run, this code produces the following output:
true true false
Related topics: