C++ String empty() function
Example
Find out if a string is empty or not:
string txt1 = "Hello World!";
string txt2 = "";
cout << txt1.empty();
cout << txt2.empty();
Try it Yourself »
Definition and Usage
The empty()
function checks wheter a string is empty or not.
It returns 1
if the string is empty, otherwise 0
.
Syntax
string.empty();
Parameters
None.
Technical Details
Returns: | A boolean value:
|
---|
Related Pages
Read more about strings in our String Tutorial.
Read more about booleans in our Booleans Tutorial.