Look these code adapted from my current develop of bg tool (
http://consolesoft.com/p/bg ):
#define UNICODE
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#undef putchar
#undef putwchar
#undef isxdigit
#undef iswxdigit
#define putchar(c) fputc(c, stdout)
#define putwchar(c) fputwc(c, stdout)
#define isxdigit(d) _isctype(d, _HEX)
#define iswxdigit(d) iswctype(d, _HEX)
#ifdef UNICODE
#define strtoul wcstoul
#define _strupr _wcsupr
#define strcmp wcscmp
#define atol _wtol
#define _isctype iswctype
#define fputc fputwc
#define ReadConsoleInput ReadConsoleInputW
#define PlaySound PlaySoundW
#else
#define ReadConsoleInput ReadConsoleInputA
#define PlaySound PlaySoundA
#endif
typedef struct {
int newmode;
} _startupinfo;
void __wgetmainargs(int *_Argc, wchar_t *** _Argv, wchar_t *** _Env,
int _DoWildCard, _startupinfo * _StartInfo);
void __getmainargs(int *_Argc, char ***_Argv, char ***_Env,
int _DoWildCard, _startupinfo * _StartInfo);
int my_main(int argc, TCHAR* argv[]);
void _start(void)
{
int argc;
TCHAR **argv;
TCHAR **env;
int ret;
_startupinfo start_info = { 0 };
#ifdef UNICODE
__wgetmainargs(&argc, &argv, &env, 0, &start_info);
#else
__getmainargs(&argc, &argv, &env, 0, &start_info);
#endif
ret = my_main(argc, argv);
exit(ret);
}
int my_main(int argc, TCHAR* argv[])
{
return 0;
}
for printf:
these:
printf("Hello %s\n", argv[0]);
using unicode you need use replace with this:
wprintf(L"Hello %ls\n", argv[0]);