開発環境 Microsoft Visual C++ 2010 Express (SP1)
実行環境 Microsoft Windows XP Home Edition (SP3)
プロジェクトの種類 Win32 コンソール アプリケーション
プロジェクト名 test
アプリケーションの種類 コンソール アプリケーション
追加のオプション 空のプロジェクト

test_mbcs.c
// マルチ バイト文字セット
#include <stdio.h>
 
int main(int argc, char *argv[])
{
	int	i;
 
	for (i = 0; argv[i] != NULL; i++) {
		printf("%d:%s\n", i, argv[i]);
	}
	return 0;
}
 

test_ucs.c
// Unicode 文字セット
#include <fcntl.h>	// _O_WTEXT
#include <io.h>		// _setmode
#include <stdio.h>	// _fileno
 
int wmain(int argc, wchar_t *argv[])
{
	int	i;
 
	_setmode(_fileno(stdout), _O_WTEXT);
	for (i = 0; argv[i] != NULL; i++) {
		wprintf(L"%d:%s\n", i, argv[i]);
	}
	return 0;
}
 

test_tchar.c
#include <fcntl.h>	// _O_WTEXT
#include <io.h>		// _setmode
#include <stdio.h>	// _fileno
#include <tchar.h>
 
int _tmain(int argc, _TCHAR *argv[])
{
	int	i;
 
#ifdef _UNICODE
	_setmode(_fileno(stdout), _O_WTEXT);
#endif
	for (i = 0; argv[i] != NULL; i++) {
		_tprintf(_T("%d:%s\n"), i, argv[i]);
	}
	return 0;
}
 
最終更新:2012年09月01日 16:43