#include#include using namespace std; int main() { string str1 = "Hello, World!"; string str2 = ""; if(str1.empty()){ cout<< "str1 is empty" << endl; } else{ cout<< "str1 is NOT empty" << endl; } if(str2.empty()){ cout<< "str2 is empty" << endl; } else{ cout<< "str2 is NOT empty" << endl; } return 0; }
str1 is NOT empty str2 is emptyIn this example, we have used the String package library, which is part of the C++ standard library.