銆怌璇█杩涢樁绡囥€戜箣鍙橀噺
Posted 灏忓垢杩恇z
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了銆怌璇█杩涢樁绡囥€戜箣鍙橀噺相关的知识,希望对你有一定的参考价值。
char, short, int, long, float, double
鍙互鍔狅細char, short, int, long
馃檯鈥嶅彲浠ュ姞锛歠loat, double
int *p1; //p1鏄竴涓寚鍚慽nt绫诲瀷鐨勬寚閽?/span>
int const *p4; //p4鍜宲2琛ㄧず鐩稿悓鐨勬剰鎬濓紝鍙槸鍐欐硶涓嶅悓
鏁版嵁绫诲瀷 |
Windows |
Linux |
||
32浣?/span> |
64浣?/span> |
32浣?/span> |
64浣?/span> |
|
char |
1 |
1 |
1 |
1 |
short (int) |
2 |
2 |
2 |
2 |
int |
4 |
4 |
4 |
4 |
long (int) |
4 |
4 |
4 |
8 |
long long |
8 |
8 |
8 |
8 |
float |
4 |
4 |
4 |
4 |
double |
8 |
8 |
8 |
8 |
long double |
8 |
8 |
12 |
16 |
char* 鎸囬拡绫诲瀷 |
4 |
8 |
4 |
8 |
size_t |
4 |
8 |
4 |
8 |
Bool |
1 |
1 |
1 |
1 |
娉細long long鏄疌++鐨?4浣嶆暣鍨嬬殑鍩烘湰绫诲瀷锛屼粠C99寮€濮嬪紩鍏ヨ繖涓蹇碉紝 C++11瀹樻柟姝e紡鏍囧噯濡備笅锛?/span>
long long - target type will have width of at least 64 bits.(since C++11)
濡備笅浠g爜鍦?2浣嶇郴缁熶腑鐨勮緭鍑虹粨鏋滄槸锛堬級
void func(char acHello[])
{
printf(鈥?d鈥? sizeof(acHello));
return;
}
void main()
{
char acHello[]=鈥滺ello鈥?
example(acHello);
return;
}
缁撴灉锛?
鍦?2浣嶇郴缁熶腑锛屾湁濡備笅浠g爜锛?/span>
char str[] = 鈥漒\\\鈥?
char *p = str;
int n = 100;
鍒檚izeof(str), sizeof(p), sizeof(n)鍒嗗埆鏄灏戯紵
缁撴灉锛? 4 4
琛ュ厖锛歴trlen(鈥淺\\\鈥?=4锛宻izeof(鈥淺\\\鈥?=5锛屼綘鐭ラ亾涓轰粈涔堝悧锛?/span>
int main()
{
short i = 65535;
printf("i=%d\n", i);
return 0;
}
缁撴灉锛?1
銆?span class="mq-337">鍒嗘瀽銆戯細鍥犱负鍐呭瓨涓?5535瀛樺偍鍐呭鐨?6杩涘埗琛ㄧず涓猴細0x0FFFF锛屽皢姝ゅ€间紶閫掔粰16浣嶇殑鍙橀噺i鏃讹紝i鍙兘鎺ュ彈鍒?xFFFF;鐪嬭棣栦綅涓?锛岀紪璇戝櫒浼氳涓篿鏄釜璐熷€硷紝鑷充簬璐熷€肩殑缁濆鍊?婧愮爜鍙栧弽锛?x0000锛?1 = 0x0001銆傚洜姝ゆ渶缁堣緭鍑?1銆?/span>
以上是关于銆怌璇█杩涢樁绡囥€戜箣鍙橀噺的主要内容,如果未能解决你的问题,请参考以下文章
Cygwin瀹夎杩涢樁鈥斺€旈€氳繃ssh鎵撳紑杩滅▼鏈嶅姟鍣℅UI绋嬪簭
绗叓璇?绗簩璁?08_02_bash鑴氭湰缂栫▼涔嬩竷 case璇彞鍙婅剼鏈€夐」杩涢樁