GameMonkey Script

GameMonkey Script Forums
It is currently Sat Apr 29, 2017 5:39 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Feb 10, 2012 10:44 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 699
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.


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 30, 2013 1:39 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 699
Updated to v1.03. Bug fix.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group