Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / sprintf Reference

Author
Message
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 24th Aug 2009 01:24 Edited at: 25th Aug 2009 09:31
I have made some documentation for the sprintf function, I thought it would be useful for beginners(This is only the basics of this function):



Feedback would be appreciated

Ps. Thanks SFCBias and DarkCoder for giving me help

int main(){
if(Self.Milkshake.BringsToYard(Boys.All))return 0;
else return 1; }
Juggalo Memnoch
16
Years of Service
User Offline
Joined: 22nd Apr 2008
Location:
Posted: 24th Aug 2009 01:28
this might be stupid but

How does it work if you want to have multiple variables printed on screen?

Do we just use the same buffer variable or do we have to define a new buffer for each variable we want printed?
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 24th Aug 2009 02:07 Edited at: 24th Aug 2009 02:11
tomtetlaw, That looks spot on

These days, it might be better to use the security enhanced version: sprintf_s
That's up to you though.


Juggalo, you could do something like this for example:
[note: untested code]


SFCBias
15
Years of Service
User Offline
Joined: 8th Aug 2009
Location: Hephzibah, GA, USA
Posted: 24th Aug 2009 03:28 Edited at: 24th Aug 2009 03:29
this is nice but there are more letters that can be used for people that want to have a different one(maybe for organization)

%c Character
%d or %i Signed decimal integer 392

%f Decimal floating point
%g Use the shorter of %e or %f
%G Use the shorter of %E or %f
%o Signed octal
%s String of characters
%u Unsigned decimal integer
%x Unsigned hexadecimal integer
%X Unsigned hexadecimal integer (capital letters)
%p Pointer address
%n Nothing printed. The argument must be a pointer to a signed int, where the number of characters written so far is stored.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 24th Aug 2009 09:28
Ok, I edited the top post to reflect your feedback.

int main(){
if(Self.Milkshake.BringsToYard(Boys.All))return 0;
else return 1; }
tomtetlaw
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location:
Posted: 24th Aug 2009 09:58
Another way to print multiple variables to the screen is to have newlines in your buffer:



int main(){
if(Self.Milkshake.BringsToYard(Boys.All))return 0;
else return 1; }

Login to post a reply

Server time is: 2024-11-20 17:23:07
Your offset time is: 2024-11-20 17:23:07