Posted on 2009-09-11 10:59
Prayer 阅读(303)
评论(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