![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c
c
1 up
这个作者很懒,什么都没留下…
展开
-
二维指针作参数的函数
原创 2020-07-30 20:30:18 · 521 阅读 · 0 评论 -
指向多维数组的指针
原创 2020-07-30 20:22:08 · 126 阅读 · 0 评论 -
指针数组以及多级指针
原创 2020-07-30 20:20:21 · 97 阅读 · 0 评论 -
通过指针将汉字字符串逆置
#include <stdio.h>#include <string.h>int main(){char str[100]=“you”;//对于VS的汉字是GBK编码,一个汉字 2个字节; 对于QT汉字是UTF8编码,一个汉字是三个字节char *str_start=&str[0];char *str_end=&str[strlen(str)-1];while(str_start<str_end){ char tem=*str_start;原创 2020-06-28 00:10:48 · 276 阅读 · 0 评论 -
指针实现计算数组第二大元素
#include <stdio.h>int smax(int a){int max=0;int s_max=0;if(a<(a+1)){max=(a+1);s_max=(a);}else{max=(a);s_max=*(a+1);}for(int i=2;i<10;i++){ if(*(a+i)>max) { int tem=max; max=*(a+i); s_max=tem; } else if(*(a+i)>s_m原创 2020-06-27 22:53:22 · 169 阅读 · 0 评论 -
指针操作实现计算字符串长度以及合并字符串
计算字符串长度#include <stdio.h>int main(){char s1[100]=“hello”;char s2[100]=“world”;int len=0;//计数char *p1=s1;while(*p1)//*p1的内容为0的时候,表示字符串结束了{ p1++; len++:}printf("字符串的长度为%d \n",len);return 0;}合并字符串#include <stdio.h>int main(){c原创 2020-06-26 00:54:09 · 379 阅读 · 0 评论 -
const指针
一、指针的兼容性原则上一定是相同类型的指针指向相同类型的变量地址,不能用一种类型的指针指向另一种类型的变量地址如:float a=3.14;int *p;p=&a;//这样是严重错误的!!!二、指向常量的指针int a=10;const int *p=&a;//p=20;//错误!!!不能通过p的方法修改一个const指针printf(“a=%d\n”,*p);//*p是个只读的值不能修改三、常量指针int a=10;int b=30;int *const p=&a原创 2020-06-25 17:04:16 · 76 阅读 · 0 评论 -
c指针
一、//地址虽然是一个整数,但地址是一个特殊的整数,是不能直接通过整数来操作的,所以用*来告诉编译器我们要取地址。如:int *p=&a;二、//int *p1;//定义一个变量,名字叫p1,他可以指向一个int的地址指针变量的值一般不能直接赋值一个整数,而是通过取变量地址的方式赋值三、//int p;int a=3;p=&a;//注意:此时p的意思是a的地址,而p的意思是a的内容(*p的意思是指针变量指向内存的内容)四、无类型指针void *p3;//这是无类型指针,意思是原创 2020-06-25 14:40:51 · 82 阅读 · 0 评论