Synapse Posted May 4, 2006 Posted May 4, 2006 (edited) 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.comso.. 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 May 4, 2006 by Bi0haZarD
LLXX Posted May 4, 2006 Posted May 4, 2006 Use width specifiers in the format string.http://www.cplusplus.com/ref/cstdio/printf.html
Synapse Posted May 4, 2006 Author Posted May 4, 2006 oohh didn't know i could do that thanks for the link, never seen that site before *bookmarks*
LLXX Posted May 5, 2006 Posted May 5, 2006 thanks for the link, never seen that site before *bookmarks*Neither have I... first result in Google for "printf" though.
Synapse Posted May 5, 2006 Author Posted May 5, 2006 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.basically all that was changed, was lined up the data. shows all IP Addresses associated with the local host and displays them..
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now