UTIL VarArgs: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
Example:
Example:
<code>
<code>
int iCreepers = 3;
int iCreepers = 3;



Revision as of 19:16, 11 April 2011

This function will build a C-String similar to printf. It is server-side only!

Example:

int iCreepers = 3;

char * pFortress = "My Awesome Fort.";

char * pOutput = UTIL_VarArgs( "There are %i creepers outside of your %s.", iCreepers, pFortress );

Msg("%s", output);


// prints: There are 3 creepers outside of your My Awesome Fortress.

This is useful for quickly building a composite string.

char * pOutput = UTIL_VarArgs( "X:%f Y:%f Z:%f\n", vec.x, vec.y, vec.z );