Wednesday, February 4, 2009

簡介C的資料型態

C has really only four types of variables:

1. char
2. int
3. float
4. double



Keyword Variable Type Range

char Character (or string) -128 to 127 (1 byte)

int Integer -32,768 to 32,767 (4 byte)

short Short integer -32,768 to 32,767 (4 byte)

short int Short integer -32,768 to 32,767 (4 byte)

long Long integer -2,147,483,648 to 2,147,483,647

unsigned char Unsigned character 0 to 255
unsigned int Unsigned integer 0 to 65,535
unsigned short Unsigned short integer 0 to 65,535
unsigned long Unsigned long integer 0 to 4,294,967,295

float Single-precision +/-3.4E10^38 to +/-3.4E10^38
floating-point
(accurate to 7 digits)

double Double-precision +/-1.7E10^308 to +/-1.7E10^308
floating-point
(accurate to 15 digits)

--

Pointer is the address in thememory.

Pointer is a data type just like int,float, and char.

int

* 4 bytes(假設硬體為32位元)
* 其內容存放2補數的整數數值
* 運算子(operator) : +,-,*(乘法),/,%,&(bitAND),|,^,~,<<,>>,=

int*

* 4 bytes(假設硬體為32位元)
* 其內容存放記憶體的地址(可視為unsigned int)
* 運算子(operator):*(透過pointer取記憶體內容),&(取變數地址),=,+,-


相關資源:

C Language Tutorial

C程式語言教學

--

How to get maximum and minimum values of data type ?


main(){
int i,j ;
i = 1;

while (i > 0) {
j = i;
i++;
}
printf ("the maximum value of integer is %d\n",j);
printf ("the value of integer after overflow is %d\n",i);
}

No comments:

Post a Comment

發表一下意見,互動一下唄!

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Adventure Book 2.0 Headline Animator

GoogleAd

funP Android 相關文章