2011年10月11日
摘要: 1,使用字符数组,代码如下:char name[]="wangtianqiao"; char *cPoint; cPoint = name ; printf("%s\n",name); printf("%c",name[4]); printf("%c",*(cPoint+4));2,使用字符指针,代码如下: char *cPoint="wangtianqiao"; printf("%s",cPoint);3,把字符串a赋值给字符串b,注意字符串都是以'\0'结 阅读全文
posted @ 2011-10-11 23:44 wtq 阅读(3698) 评论(0) 推荐(0) 编辑
摘要: 指针变量为iPoint ,整型变量为i。执行赋值:iPoint = &i;1.&*iPoint 相当于变量iPoint;2.*&i 相当于变量i; 3,(*iPoint)++是使变量a的值加14,*iPoint++ 是先使用iPoint的值,再使iPoint指向下一个变量。 5.*++iPoint 是先使iPoint指向下一个变量,然后再取出下一个变量的值。 5.指针的一个很重要的特点是可以改变实参指针变量所指变量的值,这时指针是当做函数的参数来传递的。6.在c语言中数组名代表着首元素的地址。 7,指针变量与数组:iPoint+i等价于a+i 等价于&a[i] 阅读全文
posted @ 2011-10-11 17:21 wtq 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 1,使用%x 来输出变量的地址View Code 1inti,j,k;2charch,ch1;3floatf1,f2;45printf("%x%x%x%x%x%x%x",&i,&j,&k,&ch1,&ch,&f1,&f2);6scanf("%d",&i);7printf("%d",i);8printf("%x",&i);2,观察指针变量地址的分配。经实验表明,指针变量的地址也和其他类型的变量地址分配类似,他们都处于同一块区域。如下代码:View 阅读全文
posted @ 2011-10-11 12:22 wtq 阅读(1025) 评论(0) 推荐(0) 编辑
摘要: 1,字符可以当做整型进行自加自减。代码如下:char ch ; ch=100; printf("%c",ch); while(ch>0) { printf("%c___%d ",ch,ch); ch--; }2.字符型和整型可以互相赋值char ch ; int i; ch=100; ch+=1; printf("%c",ch); i = 'a'; i+=1; 阅读全文
posted @ 2011-10-11 11:47 wtq 阅读(560) 评论(0) 推荐(0) 编辑