Last active
October 31, 2022 20:38
-
-
Save nikanos/2fecbf2e7475a83ec70c41d8efa7e8a1 to your computer and use it in GitHub Desktop.
C++ ellipsis example - Windows ShowErrorMessage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <Windows.h> | |
void ShowErrorMessage(const char* format, ...); | |
void vShowErrorMessage(const char* format, va_list argp); | |
int main() | |
{ | |
ShowErrorMessage("An error occurred!"); | |
return 1; | |
} | |
void ShowErrorMessage(const char* format, ...) | |
{ | |
va_list argp; | |
va_start(argp, format); | |
vShowErrorMessage(format, argp); | |
va_end(argp); | |
} | |
void vShowErrorMessage(const char* format, va_list argp) | |
{ | |
char errorMessage[4096]; | |
snprintf(errorMessage, sizeof(errorMessage), format, argp); | |
MessageBox(NULL, errorMessage, "Error", MB_OK | MB_ICONERROR); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ShowErrorMessage(const char* format, ...) | |
{ | |
va_list argp; | |
va_start(argp, format); | |
vShowErrorMessage(format, argp); | |
va_end(argp); | |
} | |
void vShowErrorMessage(const char* format, va_list argp) | |
{ | |
char errorMessage[4096]; | |
snprintf(errorMessage, sizeof(errorMessage), format, argp); | |
MessageBox(NULL, errorMessage, "Error", MB_OK | MB_ICONERROR); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment