07
(1
下面的程式是利用 sizeof 指令查詢 Dev C++中,各種基本資料型態所佔用的位。
01 / * prog3 11,列印出各種資料型態的長度*/
02 #include <stdio.h>
03 #include <stdlib.h>
3.4資料
04 int main(void)
051
有些時作
/* 宣告字元變數ch */
06
char ch;
/* 宣告浮點數變數 num */
數轉換店
float num;
的目的
08
/* 查詢常數 2L 所佔位元組、
09 printf ("sizeof(2L)=%d\n", sizeof (2L));
10
/* 查詢字元變數ch所佔位元組
11 printf ("sizeof (ch) =%d\n", sizeof (ch));
12 printf("sizeof(numn) =\n", sizeof(num); /* 查詢變數 num 所佔位元組
13
14 printf("sizeof(int)=sd\n", sizeof(int)); /* 查詢 int型態所佔位元組
15 printf ("sizeof (long) =8d\n", sizeof (long)); /* 查詢 long 型態所佔位元組
16 printf("sizeof(short)=%d\n", sizeof(short)); /* 查詢 short 所佔位元組 值得一
17
直接用
18 System("pause");
19 return 0;
20 )
01
02
/* prog3_11 OUTPUT---
04
sizeof (2L) = 4
05
06
07
08
09
10
03
sizeof(ch) =1
sizeof(num)=4
sizeof(int) =4
sizeof (long) =4
sizeof(short)=2
11
90 1 2 3
12
- */
*/
13