控制台输出的选项卡问题

时间:2011-04-07 18:26:05

标签: c console

我编写了我对netstat的解释。但我有一点问题 如果状态消息太长,则表格。有没有办法来解决这个问题?两个标签不会解决这个问题。

[*] nstat v.01 - maps port to process
[*] by bubblegun

Pid   Port   Proto  Status  Process

4140       80   TCP    LISTEN   httpd.exe
 916      135   TCP    LISTEN   svchost.exe
 624     1028   TCP    LISTEN   lsass.exe
3604     1031   TCP    ESTABLISHED  TeamViewer_Service.exe
3604     1032   TCP    ESTABLISHED  TeamViewer_Service.exe

1 个答案:

答案 0 :(得分:1)

尝试在printf中选择width选项。例如:

printf("%8s%8s%8s%12s %s\n", "Pid","Port","Proto","Status","Process");
printf("%8d%8d%8s%12s %s\n", 10, 200, "TCP", "LISTEN", "httpd.exe");
printf("%8d%8d%8s%12s %s\n", 101, 20100, "TCP", "ESTABLISHED", "svchost.exe");
相关问题