Print a value or a line
#Stream insertion writes values. A newline character does not request the explicit flush that std::endl does.
Fragment
Include <iostream>; place calls inside a function.
Reference
Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
C++ docs Input/output library ↗std::print ↗
Stream insertion writes values. A newline character does not request the explicit flush that std::endl does.
Fragment
Include <iostream>; place calls inside a function.
cerr is the standard error stream. Return a failure status from the owning main after resources have been released.
Fragment
Include <iostream>.
clog is a standard diagnostic stream; it does not supply a standard structured logging schema or level filter.
Fragment
Include <iostream>. Choose a logging library explicitly when you need structured records, sinks or concurrency policies.
cout inserts into stdout; \n supplies the newline. ostringstream builds text; str() returns it. quoted escapes quotes/backslashes, not every control character. Application-specific quoting helpers can define a different format. C++20 std::format returns formatted text and C++23 std::println writes it with a newline, where the standard library supports them.
Fragment
Headers plus local fragments.
fixed plus setprecision chooses decimal places. setw sets a minimum width for the next formatted field; setfill and fixed persist. imbue changes a stream’s locale. With C++20 std::format the same controls are format specs: std::format("{:.1f}", 6.2) and std::format("{:.>4}", "x").
Fragment
Headers plus independent formatting fragments.
getline writes into the string and discards its delimiter (LF by default). With CRLF bytes, CR can remain. The returned stream is usable as a success condition.
Fragment
Complete program; reads once.
from_chars reads a character range without skipping whitespace. ec reports errors; ptr marks where parsing stopped. Successful prefix parsing does not prove the whole range was consumed.
Fragment
Headers plus independent conversion fragment.
read attempts a fixed-size read; gcount reports the actual count, including a final short read. Check that count as well as stream state. sizeof gives array size in bytes here; application-defined printer/helper names are not standard stream APIs.
Fragment
Complete single-read program; no line assembly.