在看C/C++的书或者试题时,有时会见到利用word或dword定义的变量,第一次看到的时候并不知其是什么,更不用说word或dword占几个字节了。幸好在VC安装文件夹下有相关的定义。如C:\Program Files\Microsoft Visual Studio\VC98\Include查看头文件WINDEF.H的定义:
typedef unsigned long DWORD;
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef float FLOAT;
typedef FLOAT *PFLOAT;
typedef BOOL near *PBOOL;
typedef BOOL far *LPBOOL;
typedef BYTE near *PBYTE;
typedef BYTE far *LPBYTE;
typedef int near *PINT;
typedef int far *LPINT;
typedef WORD near *PWORD;
typedef WORD far *LPWORD;
typedef long far *LPLONG;
typedef DWORD near *PDWORD;
typedef DWORD far *LPDWORD;
typedef void far *LPVOID;
typedef CONST void far *LPCVOID;
从以上定义可以发现,WORD占2个字节,DWORD占4个字节。