C语言需要谨慎的问题
发布时间:2021-11-21 17:32:02 所属栏目:教程 来源:互联网
导读: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 %xncurrent *p is %dnb is %d,p,*p,b); return 0; } /*********
|
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 %xncurrent *p is %dnb 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 %dncurrent j is %dn",i,j); printf("current m is %dncurrent n is %dn",m,n); return 0; } /*****************/ sizeof把' |
