Mail Archives: djgpp/1999/07/01/13:00:32
Shawn Hargreaves wrote in message
<8D53104ECD0CD211AF4000A0C9D60AE30146182F AT probe-2 DOT acclaim-euro DOT net>...
>A. Jans-Beken writes:
>>This works all fine. But now I want to wrap this function...
>>
>> textprintf(BITMAP *bmp, FONT *f, int x, y, color, char *fmt, ...);
>>
>>I do not understand how to do this. The C++ primer that I have (old
>>edition) is inconclusive. A gues would be:
>>
>> void textprintf(int x, y, color, char *fmt, ... ) {
>> ::textprintf(bob, font, x, y, color, fmt, ... );
>> }
>
>Alternatively, there is a gcc extension that can help with this
>situation: see info "c extensions" "constructing calls". I'm not
>sure if this will work with a C++ method, though.
>
>
Sorry if this is off topic, but when I wrapped textprintf() into my own
Allegro class, I just ended up calling va_start() and vsprintf()...
I have a BmpType class with a member function Printf(const char *fmt, ...)
It looks kinda like this:
void BmpType::Printf(const char *format, ...)
{
char *buffer = new char[2048];
va_list arg;
va_start(arg, format);
vsprintf(buffer, format, arg);
va_end(arg);
Print(buffer);
// buffer is de-allocated automatically when it goes out of scope.
}
Of course, if you're gonna print more than 2k strings, you need to do
something clever :)
(Or just not print such huge damned strings :)
> Shawn Hargreaves.
- Raw text -