You can't use printf() to print a std::string because this C function doesn't know how to print a C++ string. I suggest you stick with the C++ streams when dealing with std::string. Optionally, but not recommended, you can convert the C++ string to a c_str then print that c_str with the printf.