scnlib

Modern C++ library for scanf-style input parsing with type safety.

brewmacoslinux
Try with needOr install directly
Source

About

Scanf for modern C++

Examples

parse formatted text input in C++ code$ # Include in C++ source: #include <scn/scn.h> auto result = scn::scan<int, std::string>(input, "{} {}");
read integers and strings from user input safely$ auto [num, text] = scn::scan<int, std::string>(std::cin, "{} {}").value();
extract numbers from text with error handling$ if (auto result = scn::scan<int>("42", "{}")) { int value = result.value(); }
parse multiple data types from single line$ auto result = scn::scan<int, double, char>(input, "{} {} {}");
use scanf functionality in modern C++ without format string bugs$ // Link with: -lscn // Use in CMake: find_package(scn REQUIRED) / target_link_libraries(... scn::scn)