百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

scnlib

> 编程语言
开源

使用 scanf 来实现现代 C++

1.3K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

使用 scanf 来实现现代 C++

scnlib

cpp
#include 
#include  // for std::println (C++23)

int main() {
    // Read two integers from stdin
    // with an accompanying message
    if (auto result =
            scn::prompt("What are your two favorite numbers? ", "{} {}")) {
        auto [a, b] = result->values();
        std::println("Oh, cool, {} and {}!", a, b);
    } else {
        std::println(stderr, "Error: {}", result.error().msg());
    }
}

请在 编译器浏览器 中尝试。

这是什么?

scnlib 是一个用于替换 scanf 和 std::istream 的现代 C++ 库。 这本书库试图让我们更接近于取代 iostream。 以及 C stdio。 它比 iostream 更快(参见 Benchmarks),而且类型安全,与 scanf 不同。 想想 {fmt} 或 C++20 的 std::format,但它在 另一个方向。 此库是 ISO C++ 标准提案的参考实现 P1729 "文本解析"。

文档

文档可以在 https://scnlib.dev. 上找到。

要自己构建文档,请构建 CMake 生成的 scn_docs 目标。这些目标仅在 CMake 中设置了变量 SCN_DOCS 时才会生成(如果 scnlib 是根项目,则会自动生成)。scn_docs 目标需要 Doxygen、Python 3.8 或更高版本,以及 pip3 包 poxy。

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++c-plus-pluscppinputio

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言