gpt4 book ai didi

c++ - 在 C++ 中漂亮地打印一个表

转载 作者:可可西里 更新时间:2023-11-01 15:37:12 25 4
gpt4 key购买 nike

我正在寻找一个类似于 prettytable 但在 C++ 中的库

http://code.google.com/p/prettytable/

我知道如何使用 printf 或 iostream 自己生成一个。不过,我想知道是否有这样的图书馆。

我只对将此 ASCII 表写入控制台感兴趣。

最好是这样的:

std::vector<std::string> headers;
headers.push_back("My Awesome Header 1");
headers.push_back("My Awesome Header 2");
headers.push_back("My Awesome Header 3");


PrettyTablePrinter ptp;
ptp.SetHeaders(headers);
// Set some other options here
ptp.AddRow(data[0]);
ptp.AddRow(data[1]);
ptp.AddRow(data[2]);

ptp.Print(&std::cout);

最佳答案

由于我一直没有找到好的C++解决方案,所以我写了一个给大家

https://github.com/dattanchu/bprinter/wiki

关于c++ - 在 C++ 中漂亮地打印一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4471714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com