Posted on 2009-09-11 10:59
Prayer 閱讀(307)
評論(0) 編輯 收藏 引用 所屬分類:
C/C++
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
int getLen(char *buf){
return sizeof(buf);
}
int getLen2(char buf[]){
return sizeof(buf);
}
int getLen3(char buf[256]){
return sizeof(buf);
}
int getLen4(char buf[250]){
return sizeof(buf);
}
int main(){
char bufTmp[256];
printf("%d\n",sizeof(bufTmp));
printf("%d\n",getLen(bufTmp));
printf("%d\n",getLen2(bufTmp));
printf("%d\n",getLen3(bufTmp));
printf("%d\n",getLen4(bufTmp));
printf("%d\n",strlen(bufTmp));
return 0;
}
結果
256
4
4
4
4
0