漂亮地用C ++打印表格 [英] Pretty print a table in C++

查看:108
本文介绍了漂亮地用C ++打印表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am looking for a library similar to prettytable but in C++

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

我知道如何使用printf或iostream生成自己的文件.但是,我想知道是否有一个用于此的库.

I know how to generate one myself using either printf or iostream. However, I would like to know if there is a library for this.

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

I am interested only in writing this ASCII table to the console.

最好是这样的:

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 ++解决方案,因此我为大家编写了一个

Since I have not found a good C++ solution, I have written one for you all

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

这篇关于漂亮地用C ++打印表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆