1. 32位系统下:
sizeof(int) = 4;
sizeof(long) = 4;
2. 64位系统下:
sizeof(int) = 4;
sizeof(long) = 8;
2. 如何看系统位宽:
sudo uname
sudo uname --m
编程亲测!!
#include <stdio.h> #include <stdlib.h> int chenge(const int a, int b, unsigned char buf1[] ) { unsigned char buf[1024]; b += 2; printf("chenge: b = %d ", b); printf("chenge: sizeof(buf) = %ld ", sizeof(buf)); printf("chenge: sizeof(buf1) = %ld ", sizeof(buf1)); return 0; } int main() { int inta; long longa; unsigned char buf1[1024]; int a=0, b=3; printf("main: before b= %d ", b); printf("main: sizeof(buf1)= %ld ", sizeof(buf1)); chenge(a,b,buf1); printf("main: after b= %d ", b); printf(" sizeof(int)= %ld , sizeof(long)= %ld ", sizeof(inta), sizeof(longa) ); }