精品熟女碰碰人人a久久,多姿,欧美欧美a v日韩中文字幕,日本福利片秋霞国产午夜,欧美成人禁片在线观看

C 語言實(shí)例 – 計(jì)算 int, float, double 和 char 字節(jié)大小

C 語言實(shí)例 - 計(jì)算 int, float, double 和 char 字節(jié)大小

C 語言實(shí)例 C 語言實(shí)例

使用 sizeof 操作符計(jì)算int, float, double 和 char四種變量字節(jié)大小。

sizeof 是 C 語言的一種單目操作符,如C語言的其他操作符++、--等,它并不是函數(shù)。

sizeof 操作符以字節(jié)形式給出了其操作數(shù)的存儲(chǔ)大小。

實(shí)例

#include <stdio.h> int main() { int integerType; float floatType; double doubleType; char charType; // sizeof 操作符用于計(jì)算變量的字節(jié)大小 printf("Size of int: %ld bytes\n",sizeof(integerType)); printf("Size of float: %ld bytes\n",sizeof(floatType)); printf("Size of double: %ld bytes\n",sizeof(doubleType)); printf("Size of char: %ld byte\n",sizeof(charType)); return 0; }

運(yùn)行結(jié)果:

Size of int: 4 bytes
Size of float: 4 bytes
Size of double: 8 bytes
Size of char: 1 byte

計(jì)算 long long, long double 字節(jié)大小

實(shí)例

#include <stdio.h> int main() { int a; long b; long long c; double e; long double f; printf("Size of int = %ld bytes \n", sizeof(a)); printf("Size of long = %ld bytes\n", sizeof(b)); printf("Size of long long = %ld bytes\n", sizeof(c)); printf("Size of double = %ld bytes\n", sizeof(e)); printf("Size of long double = %ld bytes\n", sizeof(f)); return 0; }

運(yùn)行結(jié)果:

Size of int = 4 bytes 
Size of long = 8 bytes
Size of long long = 8 bytes
Size of double = 8 bytes
Size of long double = 16 bytes

C 語言實(shí)例 C 語言實(shí)例

相關(guān)文章