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
Actually i want to encapsulate wsprintf inside my class.
btw. "spell check" is great :P
void __cdecl blah(...) {
return;
}
you can call it with as many params, as you like, but i don't know to access these params without using the assembly.
return;
}
you can call it with as many params, as you like, but i don't know to access these params without using the assembly.
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 .
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 .
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.
hth
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.
hth
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)
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 :)
Ultrano, if you're going to do it that way, you might as well code it in assembly - your method isn't very portable :)