#include#include #include int main() { std::string str = "Hello World"; const char* cstr = str.c_str(); std::cout << "cstr: " << cstr << std::endl; std::cout << "strlen(cstr): " << std::strlen(cstr) << std::endl; return 0; }
#includeIn this example, we create a C-style string "str" and print it and its length using standard C library functions. This example does not use the C++ standard library.#include int main() { const char* str = "Hello World"; printf("str: %s\n", str); printf("strlen(str): %zu\n", strlen(str)); return 0; }