VC常用数据类型
VC常用数据类型(2006.11.26):
类型 字节数 位数 范围 备注意:
char 1 8 -128-127
signed char 1 8 -128-127
unsigned char 1 8 0-255
short int 2 16 -32768-32767
signed short int 2 16 -32768-32767
unsigned short int 2 16 0-65535
int 4 32 -2147483648-2147483647
signed int 4 32 -2147483648-2147483647
unsigned int 4 32 0-4294967259
long int 4 32 -2147483648-2147483647
signed long int 4 32 -2147483648-2147483647
unsigned long int 4 32 0-4294967259
long 4 32 -2,147,483,648 to 2,147,483,647
float 4 32 3.4E +/- 38 (7 digits)
double 8 64 1.7E +/- 308 (15 digits)
long double 10 80 1.2E +/- 4932 (19 digits)
以下为windef.h中有关VC常用数据类型的定义:
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;
typedef int INT;
typedef unsigned int UINT;
typedef unsigned int *PUINT;
typedef WORD ATOM;
1.使用sizeof( )可以得到任何对象占用的字节数,例如如果有一个char类型的变量a, 则sizeof(a)会返1.
2.还可以借助typedef定义自己的数据类型,例如typedef myint unsigned int;后myint就等价于unsigned int.