#include "nsString.h" using namespace mozilla; nsCString str = "hello world"; bool result = str.EqualsLiteral("hello world");
#includeIn this example, we use the std::strcmp function from the C string library to compare the nsCString object directly with the string literal. We retrieve the underlying C string using the get() method of the str object. The result variable will be set to true if the two strings are equal. Package library: Mozilla Firefox.#include "nsString.h" using namespace mozilla; nsCString str = "hello world"; bool result = std::strcmp(str.get(), "hello world") == 0;