Skip to content

Instantly share code, notes, and snippets.

@7h3w4lk3r
7h3w4lk3r / debug_print.c
Last active January 23, 2025 14:51
Custom printf helper function using Win32 API instead of CRT function (printf)
#include <windows.h> // Include Windows API
// Debug print toggle, comment this to disable debug print statements
#define DEBUG_PRINT
// Function to write a string to the console
void write_to_console(const char* str, int length) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD written;
WriteConsoleA(hConsole, str, length, &written, NULL);