Skip to content

Instantly share code, notes, and snippets.

@Aetopia
Created April 2, 2024 09:22
Show Gist options
  • Save Aetopia/f13913874ce431b5a6b8f1b144627da7 to your computer and use it in GitHub Desktop.
Save Aetopia/f13913874ce431b5a6b8f1b144627da7 to your computer and use it in GitHub Desktop.
CRTless printf implementation Win32
#define printf PrintFormatA
DWORD PrintFormatA(LPCSTR lpFormat, ...)
{
va_list ArgList = NULL;
va_start(ArgList, lpFormat);
CHAR szOutput[1024] = {};
DWORD nNumberOfBytesToWrite = wvsprintfA(szOutput, lpFormat, ArgList);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), szOutput, nNumberOfBytesToWrite, NULL, NULL);
va_end(ArgList);
return nNumberOfBytesToWrite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment