Join Nostr
2026-07-01 15:24:59 UTC

CodingInLondon on Nostr: C++ nugget: printf ...

C++ nugget: printf

C:

printf("%d %d\n", x, y);

C++98: “don’t use printf, use type-safe, extensible i/o streams!”

std::cout << x << " " <<  y << '\n';

C++20: “all right all right, you can format as before”

#include <format>

std::cout << std::format("{} {}", x, y);

C++23: ”ok fine, you can have your printf back”

#include <print>

std::println("{} {}", x, y);