我正在寻找一个类似于 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);
原文由 Dat Chu 发布,翻译遵循 CC BY-SA 4.0 许可协议
由于我还没有找到好的C++解决方案,所以写了一个给大家
https://github.com/dattanchu/bprinter/wiki