nsCString str("Hello World"); printf("String is: %s\n", str.get());
void printString(nsCString str) { printf("String is: %s\n", str.get()); } int main() { nsCString str("Hello World"); printString(str); return 0; }This example shows how nsCString can be used as a parameter to a function. It creates an nsCString object with the string "Hello World" and then passes it to a function called printString(). The function uses the get() method to retrieve a pointer to the C string and then prints it to the console. Package/library: nspr4 (Netscape Portable Runtime library) is a required library for building the Mozilla Gecko codebase, which includes nsCString.