|
发表于 2019-11-1 17:17:29
|
显示全部楼层
小作业
- #include <tchar.h>
- #include <windows.h>
- #include <stdio.h>
- typedef unsigned short CcTry_UINT16;
- int CDECL MessageBoxPrintf(TCHAR *szCaption, TCHAR *szFormat, ...) {
- TCHAR szBuffer[1024];
- va_list pArgList;
- va_start(pArgList, szFormat);
- _vsntprintf(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), szFormat, pArgList);
- va_end(pArgList);
- return MessageBox(NULL, szBuffer, szCaption, MB_OK);
- }
- int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpCmdLine, INT nShowCmd) {
- size_t int32_len = sizeof(INT32);
- size_t int64_len = sizeof(INT64);
- size_t bool_len = sizeof(BOOL);
- size_t byte_len = sizeof(BYTE);
- size_t ushort_len = sizeof(USHORT);
- size_t longlong_len = sizeof(LONGLONG);
- TCHAR * output = TEXT("INT32的占%i个字节\nINT64占%i个字节\nBOOL占%i个字节\nBYTE占%i个字节\nUSHORT占%i个字节\nLONGLONG占%i个字节");
- MessageBoxPrintf(TEXT("各个数据类型所占的字节"), output, int32_len, int64_len, bool_len, byte_len, ushort_len, longlong_len);
-
- return 0;
- }
复制代码 |
|