Bubblegun
Bubblegun

Reputation: 31

Tab problem with console output

i've coded my interpretation of netstat. but i've got a little problem with the tabulators if the status message is too long. is there a way to fix this? two tabs wont solve this issue.

[*] 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

Upvotes: 0

Views: 185

Answers (1)

Zuljin
Zuljin

Reputation: 2640

Try to width option in printf. For example:

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");

Upvotes: 1

Related Questions