简体   繁体   English

如何在适当的列中打印到标准输出?

[英]How do I print to stdout in proper columns?

I have a program where I am printing to a file, and I would like to print my columns in steady columns. 我有一个程序要在其中打印到文件,我想以稳定的列打印列。

You can see here by looking at the output of my file what I am trying to say 您可以通过查看文件的输出来查看我要说的内容

Output: http://nopaste.dk/p15072 输出: http : //nopaste.dk/p15072

Here is what I wrote: 这是我写的:

int func1(int n) {
        if(n==0){return(6);}
    return ((int)log2(n));
}
char levelStrings[7] = {'L','M','H','E','F','C','X'};
fprintf(fp, "%s  %s  %d   %c    ",tString+11,log->file,log->line,levelStrings[func1(log->ssMask%64)]);

Thanks so much! 非常感谢!

(sorry that i cannot provide the input data, as they are Hex info that I have made a parser for, and it is just too much code to paste. I hope you get the general idea of what I am trying to do.) (很抱歉,我无法提供输入数据,因为它们是我为解析器准备的十六进制信息,因此粘贴的代码太多了。希望您能大致了解我要做什么。)

在以下几行中进行更改,它应该可以工作。

fprintf(fp,"%8s%8s%4d%2c",tString+11,log->file,log->line,levelStrings[func1(log->ssMask%64)]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM