#include <stdio.h>
#include <wchar.h>
#include <windows.h>
#define SIZE 32
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
// Write unicode to binary file
wchar_t unicode_buffer[SIZE] = L"ÖÉÁß";
FILE* fp;
if (fopen_s(&fp, "d:\\unicode_bin.dat", "wb") != 0) {
wprintf(L"file write error\n");
return 0;
}
fwrite(unicode_buffer, sizeof(wchar_t) * 4, 1, fp);
fclose(fp);
// Read unicode from binary file
wchar_t read_unicode_buffer[SIZE] = L"";
if (_wfopen_s(&fp, L"d:\\unicode_bin.dat", L"rb") != 0) {
wprintf(L"file not found\n");
return 0;
}
while (fread(read_unicode_buffer, sizeof(wchar_t) * 4, 1, fp)) {
MessageBox(nullptr, read_unicode_buffer, TEXT(""), 0);
}
fclose(fp);
return 0;
}
/*
run:
ÖÉÁß
*/