nsACString str = "Hello, world!"; if (str.IsEmpty()) { printf("The string is empty.\n"); } else { printf("The string is not empty.\n"); }
nsACString userInput; printf("Enter a string: "); std::cin >> userInput; if (userInput.IsEmpty()) { printf("You did not enter anything.\n"); } else { printf("You entered: %s\n", userInput.get()); }The nsACString IsEmpty method is part of the Mozilla Firefox codebase and is included in the nsStringAPI library.