Useful function vPrint(format, ...)

How to create strategies and indicators
Message
Author
Robopip
Posts: 26
Joined: Thu Jun 21, 2012 12:03 am

Useful function vPrint(format, ...)

#1 Postby Robopip » Wed Sep 12, 2012 6:06 pm

Hi,

I've made a vPrint function that I want to share with you.
I makes my life a little easier, maybe you find it useful too.

Call like this:
vPrint("sample string with variable inputs, %d, %.3f, %s", iBars(Symbol(), PERIOD_D1), 3.1415926, "Hello world");

Code:
void vPrint(char *format, ...)
{
va_list args;
char *msg;
int len;

va_start (args, format);
len = _vscprintf(format, args) + 1;
msg = (char *)malloc(len * sizeof(char));

vsprintf_s(msg, len, format, args);
va_end (args);
Print(msg);
free (msg);
}

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Thu Sep 13, 2012 5:34 am

Thank you for sharing this!
Check our other product here:
http://www.forexcopier.com


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 10 guests