string empty() in C++

empty(): It returns true if the string is empty.

This function is available in the below file.

File: basic_string.h

Parameter: No parameters are required for this function.

Syntax:

str.empty()

For Example:

str = "abc"

str.empty()=> It returns false (0) because string is not empty.

Approach

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string str = "abc";

    cout << str.empty() << "\n";
   
    return 0;
}

No comments:

Post a Comment