1、经典错误,指针变量作为函数形式参数,调用函数时、指针变量不能改变,但指针变量所指的变量可以改变:一个数组前后值对调:#includestdio.hvoidmain(){voidrev(int*p1,intn);inta[10],*p,i;p=a;for(i=0;i10;i++)scanf(%d,p+i);rev(a,10);p=a;for(i=0;i10;i++)printf(%4d,*(p+i));printf(\n);}voidrev(int*r,intn){int*p;intb[100];p=r;for(inti=0;in;i++)*(r+i)=*(p+n-1-i);}修改后的程序:#includestdio.hvoidmain(){voidrev(int*p1,intn);inta[10],*p,i;p=a;for(i=0;i10;i++)scanf(%d,p+i);rev(a,10);p=a;for(i=0;i10;i++)printf(%4d,*(p+i));printf(\n);}voidrev(int*r,intn){int*p;intb[100];p=r;for(inti=0;in;i++)b[i]=*(r+i);for(inti=0;in;i++)*(r+i)=b[n-1-i];}2、再次体验指针变量作为函数参数,指针变量单项传递由实参到形参,但是可通过函数调用改变指针变量所指的变量。错误程序:#includestdio.hvoidmain(){voidrev(int*b,intn);inta[10],i;for(i=0;i10;i++)scanf(%d,a+i);printf(\n);for(i=0;i10;i++)printf(%4d,*(a+i));printf(\n);rev(a,10);for(i=0;i10;i++)printf(%4d,*(a+i));printf(\n);}voidrev(int*b,intn){intc[100],i,j,k,min;b=c;(c=b也不可)for(i=0;in;i++)c[i]=*(b+i);for(i=0;in;i++){min=c[i];k=i;for(j=i;jn;j++)if(minc[j]){min=c[j];k=j;}c[k]=c[i];c[i]=min;}}改正:#includestdio.hvoidmain(){voidrev(int*b,intn);inta[10],i;for(i=0;i10;i++)scanf(%d,a+i);printf(\n);for(i=0;i10;i++)printf(%4d,*(a+i));printf(\n);rev(a,10);for(i=0;i10;i++)printf(%4d,*(a+i));printf(\n);}voidrev(int*b,intn){int*c,i,j,k,min;c=b;for(i=0;in;i++)c[i]=*(b+i);for(i=0;in;i++){min=c[i];k=i;for(j=i;jn;j++)if(minc[j]){min=c[j];k=j;}c[k]=c[i];b[i]=min;}}3、计算机中int*p;(p)和(p+1)到底相差几;我认为是4;可计算机执行的为1#includestdio.h#defineF%d,%d\n#definePprintfvoidmain(){inta[3][4]={1,3,5,7,9,11,13,15,17,19,21,23};int*p;for(p=a[0];pa[0]+12;p++){if((p-a[0])%4==0)/*换为16不可*/P(\n);P(%3d,*p);}P(\n);}指针变量存的是地址,但是指针变量之间的值相加有点奇怪:#includestdio.h#defineF%d,%d\n#definePprintfvoidmain(){inta[3][4]={1,3,5,7,9,11,13,15,17,19,21,23};int*p;for(p=a[0];pa[0]+12;p++){if((p-a[0])%4==0)/*换为16不可*/P(\n);P(%3d,*p);}P(\n);for(p=a[0];pa[0]+12;p++){P(%d\n,p-a[0]);P(addr=%d,value=%d\n,p,*p);}}4、定义的指针变量,在指向二维数组时一定要注意是指向列(指向元素),还是指向行(一维数组);例:int*p;a[10][5];p=a指向数组;p=a[0]指向列(元素)。5、用指针变量指向二维数组时,一定要注意指针是指行还是指列,否则出错,错误程序:#includestdio.hvoidmain(){inta[3][4]={1,3,5,7,9,11,13,15,17,19,21,23};int*p;p=a;inti,j;scanf(%d,%d,&i,&j);printf(a[%d][%d]=%d\n,i,j,*(*(p+i)+j));}定义的指针指向列(元素),所以对指针赋值语句错误,改正:#includestdio.hvoidmain(){inta[3][4]={1,3,5,7,9,11,13,15,17,19,21,23};int(*p)[4];p=a;inti,j;scanf(%d,%d,&i,&j);printf(a[%d][%d]=%d\n,i,j,*(*(p+i)+j));}指针变量指行(一维数组)6、指向变量的指针变量(列、元素地址int*p,p=a[0]),指向一维数组的指针变量(行、二维数组名int(*p)[4],p=a)。其中a[3][4]。#includestdio.hvoidmain(){floatave(float*a,intn);floata[3][4],s;intm;scanf(%d,&m);printf(inputthegrades:\n);float*p;for(p=a[0];pa[0]+12;p++)scanf(%f,p);p=a[0];s=ave(p,12);printf(average=%f\n,s);for(p=a[m-1];pa[m-1]+4;p++)printf(%6f,*p);printf(\n);}floatave(float*a,intn){floatc=0,*r;r=a;for(inti=0;in;i++)c=c+*(r+i);c=c/n;return(c);}6、定义二维数组行可以空,但是列不可以空。#includestdio.hvoidmain(){voidsearch(float(*p)[4],intn);floata[3][4],*p;for(p=a[0];pa[0]+12;p++)scanf(%f,p);search(a,3);}voidsearch(float(*p)[4],intn){floatt;for(inti=0;in;i++)for(intj=0;j4;j++){t=*(*(p+i)+j);if(t60){printf(thefallsNO.%dis\n,i);for(intl=0;l4;l++)printf(%6f,*(*(p+i)+l));printf(\n);}}}7、C语言对字符串常量按字符数组处理的。Vs处理不了的:#includestdio.hvoidmain(){char(*string)=IloveChina;printf(%s\n,string);}8、#includestdio.hvoidmain(){chara[]=Iamboy,b[20];inti;for(i=0;*(a+i)!='\0';i++)*(b+i)=*(a+i);*(b+i)='\0';/*没该语句会乱码输出*/printf(thearrayais:%s\n,a);printf(thearraybis:%s\n,b);}另一个程序:#includestdio.hvoidmain(){voidcopy(charstring1[100],charstring2[100]);chara[]=Iamateacher,b[]=Iamastudent;printf(a=%s\n,a);printf(b=%s\n,b);printf(copyatob\n);copy(a,b);printf(a=%s\n,a);printf(b=%s\n,b);}voidcopy(charstr1[100],charstr2[100]){inti;for(i=0;*(str1+i)!='\0';i++)*(str2+i)=*(str1+i);*(str2+i)='\0';}%s格式输出字符串时,遇‘\0’结束,而%c则不然,在输出字符串时,会输出字符数组定义的长度。数组名虽然代表地址,但他是常量,值不能随意改变!定义指针变量指向字符串后,就可以用下标形式引用指针变量所指字符串中的字符!Printf(“格式字符串”),可以用指针表示,输出遇到‘\0’结束。函数名代表该函数的入口地址。9、咱可以定义函数时调用函数,但是不可以调用被调用函数的参数。#includestdio.hvoidmain(){intprogress(int(*p)(inti,intj),inti,intj);intmax(inti,intj);intmin(inti,intj);intsub(inti,intj);inti,j;scanf(%d,%d,&i,&j);printf(%d\n,progress(max,i,j));printf(%d\n,progress(min,i,j));printf(%d\n,progress(sub,i,j));}intmax(inti,intj){intc;c=ij?i:j;return(c);}intmin(inti,intj){intc;c=ij?i:j;return(c);}intsub(inti,intj){return(i+j);}intprogress(int(*p)(inti,intj),inti,intj){intc;c=(*p)(i,j);return(c);}10、求积分#includestdio.h#includemath.hvoidmain(){floatintergral(floata,floatb,float(*fun)(floata));floatf1(floatx);floatf2(floatx);floatf3(floatx);floata,b;scanf(%f,%f,&a,&b);printf(%f\n,intergral(a,b,f1));printf(%f\n,intergral(a,b,f2));printf(%f\n,intergral(a,b,f3));}floatf1(floatx){floaty;y=exp(x)+1;return(y);}floatf2(floatx){floaty;y=(x+1)*(x+1);return(y);}floatf3(floatx){floaty;y=pow(x,3);return(y);}floatintergral(floata,floatb,float((*fun)(floatx))){floaty=0,t=a;for(inti=0;t=b;i++){t=a+0.00001*i;y=y+abs((*fun)(t))*0.00001;}return(y);}11、返回指针值#includestdio.hvoidmain(){floatscore[][4]={60,70,80,90,56,89,67,88,34,78,90,66};float*pointer(float(*p)[4],intn);float*p;intm;sca