GameMonkey Script
http://www.gmscript.com/gamemonkey/forum/

FormatString replacement for snprintf style functions v1.03
http://www.gmscript.com/gamemonkey/forum/viewtopic.php?f=12&t=596
Page 1 of 1

Author:  Greg [ Fri Feb 10, 2012 10:44 am ]
Post subject:  FormatString replacement for snprintf style functions v1.03

Here are some functions to implement or replace snprintf and scanf.
The motivation was to implement for platforms without native standard library, handle 64bit ints and floats, improve type safety, avoid C variable arguments and allow optional .net style syntax.

You can download the source here FormatString_1_03.zip

Example usage:
Code:
#include "FormatString.h"
#include "FormatStringF.h"
#include "ScanStringF.h"

char buffer[256];
FormatString(buffer, 256, "Count: {0} value: {1:F3}", 34, 123.456789);
FormatStringF(buffer, 256, "Count: %d value: %.3f", 34, 123.456789);

int count = 0;
float value = 0.0f;
ScanStringF("Count: 34 value: 123.457", "Count: %d value: %f", &count, &value);


Edit: Updated to v1.01 - fixed accidentally introduced bug.
v1.02 - Spelling, insignificant change
v1.03 - Fix exception when non string value requested string format.

Author:  Greg [ Sat Nov 30, 2013 1:39 am ]
Post subject:  Re: FormatString replacement for snprintf style functions v1

Updated to v1.03. Bug fix.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/