How can i make a method in C++ that works just like wsprintf, i mean with changeable variables number;

Actually i want to encapsulate wsprintf inside my class.

btw. "spell check" is great :P

Posted on 2005-05-28 17:36:23 by AceEmbler
void __cdecl blah(...) {

you can call it with as many params, as you like, but i don't know to access these params without using the assembly.
Posted on 2005-05-28 18:11:46 by ti_mo_n
void __cdecl blah(long dummyArgument,...){
long *args = &dummyArgument;
// accessing arguments:
long arg0 = args[0];
long arg1 = args[1];
long arg2 = args[2];
char* lpszString1 = (char*) args[3];

But accessing variables >4bytes in size, I don't know - you should look at the assembly listing of such a proc .
Posted on 2005-05-29 02:30:38 by Ultrano
You can use the functions in stdarg.h to access the variable arguments - see msdn for examples etc.

There is no way to know how many arguments were passed, though, so you have to infer that by passing a number indicating how many or a special 'end' argument... you will see on msdn.


Posted on 2005-05-29 08:43:16 by stormix
I dropped this one. C++ lacks Asm flexibility (maybe i will use inline assembly for this one)    (this is a flame, or rather Crusade :P)
Posted on 2005-05-29 10:19:41 by AceEmbler
AceEmbler, check up on stdarg.h as suggested by stormix, it works fine.

Ultrano, if you're going to do it that way, you might as well code it in assembly - your method isn't very portable :)
Posted on 2005-05-29 19:41:31 by f0dder