Writing to the standard output (which is what sys.stdout
.write
does in Python) is generally done via the std::cout
stream and the <<
operator:
std::cout << frame.tostring();
Include the <iostream>
header. The cout
object is a descendant of std::ostream
, so you can do all the things with it that the documentation says you can do with an ostream
.
You can also use C-style I/O. The printf
and puts
functions (in the <cstdio>
header) will write a string to standard output:
std::printf("%s", frame.tostring().c_str());
std::puts(frame.tostring().c_str()); // also writes '\n' afterward
Here I'm assuming your tostring
function returns a std::string
; the C-style functions only print null-terminated char
pointers, not string
, so I call c_str
. The <<
operator, on the other hand, is overloaded to handle most of the common C++ types, so you can print them without calling extra functions.