Jump to content

[C++] line up output from printf()


Recommended Posts

hello, haven't been on these forums lately.. but been tryin to learn some more into C++ since i never really "understood" the language.

anyways... i found Source Code of a packet sniffer that i want to improvise on to learn from.

*yes i'm retaining all credits lol*

so i decided to compile it after adding wsock32.lib and w2_32.lib to the linker. and first thing i noticed that i wanted to change was the line up of the data..

Screenshot of me browsing download.com

so.. my question is.. is there anyway to line up the output so it's all in nice columns that? i tried \t (tab) but it gives me a space of about 5 characters but does line it up..

heres a snip of the source code from the link above. Made by KT.

memset(&SockAddr, 0, sizeof(SockAddr));
SockAddr.sin_addr.s_addr = iphdr->SrcIP;
printf("Packet From: %s ", inet_ntoa(SockAddr.sin_addr));
memset(&SockAddr, 0, sizeof(SockAddr));
SockAddr.sin_addr.s_addr = iphdr->DstIP;
printf("To: %s ", inet_ntoa(SockAddr.sin_addr));

Edited by Bi0haZarD
Link to comment
Share on other sites


yea didn't occur to me to just google up "printf" figured it would've been more complex lol.

anyways, think i made the final touches i wanted :) heres a screenshot after my changes for kicks.

modified0af.jpg

basically all that was changed, was lined up the data. shows all IP Addresses associated with the local host and displays them..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...