Last active
March 20, 2025 04:15
-
-
Save noqisofon/07a55b20109a03dda3858b0dcdb45897 to your computer and use it in GitHub Desktop.
( ノ╹◡◡╹)ノ 🦑を C++ で表示してみた
This file contains 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 <assert.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <wchar.h> | |
#include <Windows.h> | |
auto main() -> int { | |
wchar_t buffer[256] = {}; | |
int32_t writes{ 0 }; | |
#if defined( __MSYS__ ) || defined( __MINGW32__ ) || defined( __MINGW64__ ) | |
writes = swprintf( buffer, 256, L"%s\n", L"🦑" ); | |
#else | |
writes = swprintf_s( buffer, L"%s\n", L"🦑" ); | |
#endif | |
HANDLE standard_output_handle{ GetStdHandle( STD_OUTPUT_HANDLE ) }; | |
DWORD chars_to_write{ static_cast<DWORD>( wcslen( buffer ) ) }; | |
DWORD got{ 0 }; | |
assert( static_cast<uint32_t>( writes ) == chars_to_write ); | |
BOOL done = WriteConsoleW( standard_output_handle, buffer, chars_to_write, &got, nullptr ); | |
assert( done ); | |
assert( got == chars_to_write ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment