#include#include using namespace std; int main() { string str = "Hello World"; if(str.empty()){ cout << "The string is empty" << endl; }else{ cout << "The string is not empty" << endl; } return 0; }
#includeThis code checks if the string "str" is empty or not. Since it is empty, the output will be "The string is empty". The tstring empty function is part of the Standard Template Library (STL) package.#include using namespace std; int main() { string str; if(str.empty()){ cout << "The string is empty" << endl; }else{ cout << "The string is not empty" << endl; } return 0; }