C/C++基本数据类型

There are five data types for C: void, integer, float, double, and char.

TypeDescription
void associated with no data type
int integer
float floating-point number
double double precision floating-point number
char character

 

 

 

 

 

  

C++ defines two more: bool and wchar_t.

TypeDescription
bool Boolean value, true or false
wchar_t wide character

 

 

 

Type Modifiers

Several of these types can be modified using signed, unsigned, short, and long. When one of these type modifiers is used by itself, a data type of int is assumed. A complete list of possible data types follows:

bool
char
unsigned char
signed char
int
unsigned int
signed int
short int
unsigned short int
signed short int
long int
signed long int
unsigned long int
float
double
long double
wchar_t

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

char是8位字符类型,最多只能包含256种字符,许多外文字符集所含的字符数目超过256个,char型无法表示。
 
wchar_t数据类型一般为16位或32位,但不同的C或C++库有不同的规定,如GNU Libc规定wchar_t为32位 ,总之,wchar_t所能表示的字符数远超char型。
 
标准C++中的wprintf()函数以及iostream类库中的类和对象能提供wchar_t宽字符类型的相关操作。

 

posted @ 2015-03-24 10:27  薛晓东  阅读(125)  评论(0)    收藏  举报