Coon (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Mit dieser Hilfsfunktion kann man die log-Funktion wie printf benutzen: <pre> static void logf(API* api, const char* pFormat, ...) { va_list args; va_star…“) |
Coon (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| (Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt) | |||
| Zeile 2: | Zeile 2: | ||
<pre> | <pre> | ||
static void logf( | #include <stdio.h> | ||
#include <stdarg.h> | |||
static void logf(Api* api, const char* pFormat, ...) { | |||
va_list args; | va_list args; | ||
va_start(args, pFormat); | va_start(args, pFormat); | ||
Aktuelle Version vom 1. Juni 2019, 15:22 Uhr
Mit dieser Hilfsfunktion kann man die log-Funktion wie printf benutzen:
#include <stdio.h>
#include <stdarg.h>
static void logf(Api* api, const char* pFormat, ...) {
va_list args;
va_start(args, pFormat);
char* pBuf;
vasprintf(&pBuf, pFormat, args);
va_end(args);
api->log(pBuf);
free(pBuf);
}