在表中格式化输出,C ++ [英] Format output in a table, C++

查看:171
本文介绍了在表中格式化输出,C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C ++中的表格将数据输出到控制台?在C#中有一个问题,但我需要在C ++中。



除了在C ++中:如何:在控制台应用程序(C#)中绘制表格的最佳方式

$你不能做类似于C#示例的非常类似的操作:



<$ p $

p> String.Format(| {0,5} | {1,5} | {2,5} | {3,5} |,arg0,arg1,arg2,arg3);

Like:

 code> printf(|%5s |%5s |%5s |%5s |,arg0,arg1,arg2,arg3); 

这里是我用来做这个的引用: http://www.cplusplus.com/reference/clibrary/cstdio/printf/


How can I output data to the console in a table in C++? There's a question for this in C#, but I need it in C++.

This, except in C++: How To: Best way to draw table in console app (C#).

解决方案

Can't you do something very similar to the C# example of:

String.Format("|{0,5}|{1,5}|{2,5}|{3,5}|", arg0, arg1, arg2, arg3);

Like:

printf("|%5s|%5s|%5s|%5s|", arg0, arg1, arg2, arg3);

Here's a reference I used to make this: http://www.cplusplus.com/reference/clibrary/cstdio/printf/

这篇关于在表中格式化输出,C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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