Raised This Month: $ Target: $400
 0% 

ok can someone explain this line of code.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-24-2005 , 04:58   ok can someone explain this line of code.
Reply With Quote #1

Quote:
console_print(id,"%2d %-16.15s %-20s %-8d %-4.3s %-4.3s %s", players[a],name,authid,
get_user_userid(players[a]),(flags&ADMIN_IMMUNITY)?lYes:lNo,
(flags&ADMIN_RESERVATION)?lYes:lNo,sflags)
Quote:
Originally Posted by This is the part of the code i want to be explained.
"%2d %-16.15s %-20s %-8d %-4.3s %-4.3s %s"
I see %s %d %s %s %s, i understand that but i don't under -20 -8 -4.3 -4.3 is that suppose to be tab spacing when it printed?

I want to know because i'm writing a simple script for my server so i can just see people ip.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-24-2005 , 12:18  
Reply With Quote #2

Yes, they are basically place holders..

%-23.45f for example, means that the output will be left-aligned (the minus sign), there will be space for 16 numbers before the decimal (if the number was 23.45 then there would be 14 spaces in front of the number 23) and finally the .15 means that the output may have upto 15 precision points after the decimal (which sometimes gets padded with zeros, not sure if that happens in Small tho or not)

So 23.45 may look something like:

_ _ _ _ _ _ _ _ _ _ _ _ _ _23.450000000000000


At least that's what I remember from C/C++...

But what is strange is that they have the modifiers for a string (%s) which I have never seen done before..
xeroblood is offline
Send a message via MSN to xeroblood
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:05.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode