xcxvbf 2013-05-14
1、*p++,*++p,*(p++),*(++p)
这四种书写不等价
/*********test p *******/
int _tmain(int argc, _TCHAR* argv[])
{
int b
int a[]={1,2,3};
int *p;
p=&a[1];
b=*++p;
printf("current p is %x\ncurrent *p is %d\nb is %d",p,*p,b);
return 0;
}
/*****************/
2、sizeof与strlen的区别
sizeof是运算符
strlen是函数,在驱动开发中不可用
/*********test strlen()*******/
int _tmain(int argc, _TCHAR* argv[])
{
char s[]="abcdef";
int i=strlen(s);
int j=sizeof(s);
char c[]={'a','b','c','d','e','f'};
int m=strlen(c);
int n=sizeof(c);
printf("current i is %d\ncurrent j is %d\n",i,j);
printf("current m is %d\ncurrent n is %d\n",m,n);
return 0;
}
/*****************/
sizeof把'\0'包括在内
但是strlen却不包括,只有遇到时,才终止。