WORD与DWORD
在看C/C++的书或者试题时,有时会见到利用word或dword定义的变量,第一次看到的时候并不知其是什么,更不用说word或dword占几个字节了。幸好在VC安装文件夹下有相关的定义。如C:Program FilesMicrosoft VisualStudioVC98Include查看头文件WINDEF.H的定义:
typedef unsignedlongDWORD;
typedefintBOOL;
typedef unsignedcharBYTE;
typedef unsignedshortWORD;
typedeffloatFLOAT;
typedefFLOAT*PFLOAT;
typedef BOOLnear*PBOOL;
typedef BOOLfar*LPBOOL;
typedef BYTEnear*PBYTE;
typedef BYTE far*LPBYTE;
typedef intnear*PINT;
typedef intfar*LPINT;
typedef WORDnear*PWORD;
typedef WORDfar*LPWORD;
typedef longfar*LPLONG;
typedef DWORDnear*PDWORD;
typedef DWORDfar*LPDWORD;
typedef voidfar*LPVOID;
typedef CONST voidfar*LPCVOID;
从以上定义可以发现,WORD占2个字节,DWORD占4个字节。