当前位置: 首页 > news >正文

考试系统 微网站是什么样的大学生网络营销策划方案书

考试系统 微网站是什么样的,大学生网络营销策划方案书,任何用c语言做网站,wordpress出现的常见问题代码分析 9. 指针和数组代码解析一维数组字符数组字符串二维数组 10. 指针代码分析eg1eg2eg3eg4eg5eg6eg7eg8 10.1 指针进阶_数组指针 10.2 指针进阶_函数指针 9. 指针和数组代码解析 数组名arr是首元素地址 例外: 1. sizeof(arr),计算整个数组的大小&…

代码分析

  • 9. 指针和数组代码解析
    • 一维数组
    • 字符数组
    • 字符串
    • 二维数组
  • 10. 指针代码分析
    • eg1
    • eg2
    • eg3
    • eg4
    • eg5
    • eg6
    • eg7
    • eg8

10.1 指针进阶_数组指针
10.2 指针进阶_函数指针

9. 指针和数组代码解析

数组名arr是首元素地址
例外:
1. sizeof(arr),计算整个数组的大小,sizeof内部单独放一个数组名,数组名表示整个数组。  
2. &arr,取出的是 数组的地址。&数组名,数组名表示 整个数组。  
除此1,2两种情况之外,所有的数组名都表示数组首元素的地址

一维数组

int a[] = { 1,2,3,4 };
printf("%d\n", sizeof(a));//数组大小-->4*4=16 byte
printf("%d\n", sizeof(a+0));//a首元素地址,a+0-->4/8 byte
printf("%d\n", sizeof(*a));//a首元素地址,解引用*a,首元素大小-->4 byte
printf("%d\n", sizeof(a+1));//a+1-->4/8 byte
printf("%d\n", sizeof(a[1]));//第二个元素大小-->4 byte
printf("%d\n", sizeof(&a));//数组地址&a-->4/8 byte
printf("%d\n", sizeof(*&a));
//*&a --> a --> 数组地址&a,解引用*&a,数组大小大小-->16 byte
//&a  --> int(*)[4] -->类型
//    --> *&a --> a[4] 16 byte
printf("%d\n", sizeof(&a+1));//相对于&a,跳过了整个数组,地址大小-->4/8 byte
printf("%d\n", sizeof(&a[0]));//首元素地址-->4/8 byte
printf("%d\n", sizeof(&a[0]+1));//第二个元素地址-->4/8 byte

字符数组

char arr[] = {'a','b','c','d','e','f'};  
printf("%d\n", sizeof(arr));//整个数组大小 --> 6 byte
printf("%d\n", sizeof(arr+0));//首元素地址 --> 4/8 byte
printf("%d\n", sizeof(*arr));//首元素大小 --> 1 byte
printf("%d\n", sizeof(arr[1]));//第二个元素大小 --> 1 byte
printf("%d\n", sizeof(&arr));//数组地址 --> 4/8byte 
printf("%d\n", sizeof(&arr+1));//相对于&arr,跳过了整个数组,地址-->4/8 byte
printf("%d\n", sizeof(&arr[0]+1));//首元素地址+1,第二个元素地址-->4/8 byteprintf("%d\n", strlen(arr));//strlen读到\0才结束,统计\0前字符串个数,随机值
printf("%d\n", strlen(arr+0));//首元素地址arr+0,随机值
printf("%d\n", strlen(*arr));//err,strlen参数部分需要传地址
//*arr是首元素a,a的ASCII码位97,strlen从97开始统计字符串长度,非法访问内存
printf("%d\n", strlen(arr[1]));//err
printf("%d\n", strlen(&arr));//&arr --> char(*)[6],数组地址,随机值
printf("%d\n", strlen(&arr+1));//随机值
printf("%d\n", strlen(&arr[0]+1));//第二个元素地址,随机值
char arr[] = "abcdef";//[a b c d e f \0]
printf("%d\n", sizeof(arr));//数组大小 --> 7
printf("%d\n", sizeof(arr+0));//首元素地址 --> 4/8
printf("%d\n", sizeof(*arr));//首元素 --> 1
//*arr --> *(arr + 0) --> arr[0]
printf("%d\n", sizeof(arr[1]));//第二元素 --> 1
printf("%d\n", sizeof(&arr));//数组地址 --> 4/8
printf("%d\n", sizeof(&arr+1));//数组地址+1 --> 4/8
printf("%d\n", sizeof(&arr[0]+1));//第二元素地址 --> 4/8printf("%d\n", strlen(arr));//数组地址 6
printf("%d\n", strlen(arr+0));//首元素地址 6
printf("%d\n", strlen(*arr));//err 首元素a
printf("%d\n", strlen(arr[1]));//err 首元素a 
printf("%d\n", strlen(&arr));//数组地址 6
printf("%d\n", strlen(&arr+1));//数组地址+1 random
printf("%d\n", strlen(&arr[0]+1));//第二元素地址 5

字符串

char* p = "abcdef";//[a b c d e f \0],p存放a的地址
printf("%d\n", sizeof(p));//指针p 4/8
printf("%d\n", sizeof(p+1));//b的地址 4/8
printf("%d\n", sizeof(*p));//a 1
printf("%d\n", sizeof(p[0]));//a 1
//*p --> *(p + 0) --> p[0]
printf("%d\n", sizeof(&p));//p的地址 4/8
//&p --> char**
printf("%d\n", sizeof(&p+1));//p的地址+1 4/8
printf("%d\n", sizeof(&p[0]+1));//b的地址+1 4/8printf("%d\n", strlen(p));//a的地址 6
printf("%d\n", strlen(p+1));//b的地址 5
printf("%d\n", strlen(*p));//err,a
printf("%d\n", strlen(p[0]));//err,a
printf("%d\n", strlen(&p));//p的地址 random
printf("%d\n", strlen(&p+1));//p的地址+1 random
printf("%d\n", strlen(&p[0]+1));//b的地址 5

二维数组

int a[3][4] = {0};  
printf("%d\n",sizeof(a));//数组a大小 3*4*4=48
printf("%d\n",sizeof(a[0][0]));//[0][0]元素 4
printf("%d\n",sizeof(a[0]));//[0]行数组大小 4*4=16
//每行都是二维数组的一个元素,一维数组的数组
//a[0]是第一行一维数组的 数组名
printf("%d\n",sizeof(a[0]+1));//第1行数组第二个元素地址 4/8
printf("%d\n",sizeof(*(a[0]+1)));//第2行数组首元素大小 4
printf("%d\n",sizeof(a+1));//a是首元素地址,是第一行的地址,a+1是第2行地址 4/8
printf("%d\n",sizeof(*(a+1)));//第2行数组大小 4*4=16
printf("%d\n",sizeof(&a[0]+1));//&a是第1行的地址,a+1是第2行地址 4/8
printf("%d\n",sizeof(*(&a[0]+1)));//第2行数组大小 4*4=16
printf("%d\n",sizeof(*a));//第1行数组大小 4*4=16
//a 首元素地址,第1行地址
//*a 第1行
//*a --> *(a+0) --> a[0] 
printf("%d\n",sizeof(a[3]));//第4行数组大小 4*4=16
//a[3] --> int [4]
//sizeof()只关注类型,不会计算

10. 指针代码分析

eg1

int main()  
{  int a[5] = { 1, 2, 3, 4, 5 };int *ptr = (int *)(&a + 1);//&a 取出 数组地址,&a+1 向后跳一个数组长度 的地址printf( "%d,%d", *(a + 1), *(ptr - 1));//(a+1) 首元素地址+1,第二元素地址。*(a+1) --> 2//ptr 是a[5]向后跳一个数组长度 的地址//(ptr - 1) 向前访问4byte --> 5return 0;  
}

eg2

//结构体的大小是20个字节
struct Test  
{  int Num;//4char *pcName;//1short sDate;//2char cha[2];//1short sBa[4];//2 
}*p = (struct Test*)0x100000;
//结构体Test类型的变量大小是20个字节
int main()  
{  printf("%p\n", p + 0x1);//跳过一个结构体 20byte//0x100000 + 0x000014 = 0x100014printf("%p\n", (unsigned long)p + 0x1);//整形+1byte --> 0x100001printf("%p\n", (unsigned int*)p + 0x1);//跳过+4byte --> 0x100004return 0;  
}

eg3

int main()  
{  int a[4] = { 1, 2, 3, 4 };//小端 [01 00 00 00| 02 00 00 00 00| 03 00 00 00| 04 00 00 00]int *ptr1 = (int *)(&a + 1);//&a 取出数组地址,&a+1 向后跳一个数组长度 的地址int *ptr2 = (int *)((int)a + 1);//(int)a a地址的值+ 1byte printf( "%x,%x", ptr1[-1], *ptr2);//%x --> 16进制打印//ptr1[-1] --> 4//*ptr2 --> 01 |00 00 00 02| -->2000000return 0;
}

请添加图片描述

eg4

#include <stdio.h>  
int main()  
{  int a[3][2] = { (0, 1), (2, 3), (4, 5) };//(0,1) --> 1. {0,1} is right//{{1,3}, {5,0}, {0,0}};int *p;p = a[0];//a是首元素地址,即第一行地址,a[0][0]的地址printf( "%d", p[0]);//p[0] --> *(p+0) -->*p --> 1return 0;
}

eg5

int main()  
{  int a[5][5];  int(*p)[4];  p = a;  printf( "%p,%d\n", &p[4][2] - &a[4][2], // -4&p[4][2] - &a[4][2]);  return 0;  
}

请添加图片描述

-4 -->
10000000 00000000 00000000 00000100
11111111 11111111 11111111 11111011
1111 1111 1111 1111 1111 1111 1111 1100
F    F    F    F    F    F    F    C 
0xFFFFFFFC

eg6

int main()  
{  int a[2][5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };int *ptr1 = (int *)(&a + 1);//数组地址+1,跳过一个数组的大小int *ptr2 = (int *)(*(a + 1));//第一行地址+1=第二行地址,*解引用 --> a[1][0]//a + 1 类型为 int (*)[5] 指向二维数组 a 的第二行//*(a + 1) 表示指向二维数组 a 第二行首元素的指针,它指向的是 a[1][0]//*(a + 1) --> a[1]数组名 --> 首元素地址&a[1][0]printf( "%d,%d", *(ptr1 - 1), *(ptr2 - 1));//ptr1 -1 --> 10//ptr2 -1 --> 5return 0;  
}

eg7

#include <stdio.h>  
int main()  
{  char* a[] = {"work","at","sangfor"};//char* p = "sangfor";//存放字符串首字符地址char** pa = a;//pa存放数组名pa++;// wo --> aprintf("%s\n", *pa);return 0;  
}

eg8

int main()  
{  char* c[] = {"ENTER","NEW","POINT","FIRST"};//指针数组,存放首字符地址char** cp[] = {c+3, c+2, c+1, c};char*** cpp = cp;printf("%s\n", **++cpp);//POINTprintf("%s\n", *--*++cpp+3);printf("%s\n", *cpp[-2]+3);printf("%s\n", cpp[-1][-1]+1);return 0;
}

请添加图片描述

printf("%s\n", ** ++cpp);//POINT     注意:cpp值已经更改

请添加图片描述

printf("%s\n", *--*++cpp+3);//ER

请添加图片描述

printf("%s\n", *cpp[-2]+3);//ST

请添加图片描述

printf("%s\n", cpp[-1][-1]+1);//EW

请添加图片描述
10.1 指针进阶_数组指针
10.2 指针进阶_函数指针


文章转载自:
http://pangolin.c7493.cn
http://inexpedient.c7493.cn
http://micrometeor.c7493.cn
http://landscaper.c7493.cn
http://screenwash.c7493.cn
http://sunspot.c7493.cn
http://snockered.c7493.cn
http://encage.c7493.cn
http://althorn.c7493.cn
http://justiciar.c7493.cn
http://agrochemical.c7493.cn
http://profanely.c7493.cn
http://flatfish.c7493.cn
http://pliably.c7493.cn
http://niblick.c7493.cn
http://watchmaking.c7493.cn
http://cosmonaut.c7493.cn
http://joshua.c7493.cn
http://earn.c7493.cn
http://whitethroat.c7493.cn
http://mobilise.c7493.cn
http://tiemannite.c7493.cn
http://unanswerable.c7493.cn
http://cytophotometer.c7493.cn
http://joyously.c7493.cn
http://possibilist.c7493.cn
http://liposarcoma.c7493.cn
http://farl.c7493.cn
http://lymphocytosis.c7493.cn
http://standpoint.c7493.cn
http://glycogenase.c7493.cn
http://clomb.c7493.cn
http://forgetfully.c7493.cn
http://longyi.c7493.cn
http://outpour.c7493.cn
http://manjak.c7493.cn
http://arenaceous.c7493.cn
http://contortions.c7493.cn
http://aah.c7493.cn
http://jewelry.c7493.cn
http://coadjutress.c7493.cn
http://djakarta.c7493.cn
http://ruching.c7493.cn
http://snockered.c7493.cn
http://upanishad.c7493.cn
http://centralization.c7493.cn
http://fos.c7493.cn
http://arbitration.c7493.cn
http://chinela.c7493.cn
http://destabilize.c7493.cn
http://shawwal.c7493.cn
http://maintopmast.c7493.cn
http://special.c7493.cn
http://fascicule.c7493.cn
http://anisole.c7493.cn
http://replier.c7493.cn
http://mossycup.c7493.cn
http://abruptness.c7493.cn
http://letterform.c7493.cn
http://monging.c7493.cn
http://prorogation.c7493.cn
http://noy.c7493.cn
http://jambi.c7493.cn
http://latifundist.c7493.cn
http://accommodate.c7493.cn
http://megimide.c7493.cn
http://tetraiodothyronine.c7493.cn
http://cultipacker.c7493.cn
http://wooingly.c7493.cn
http://heller.c7493.cn
http://empty.c7493.cn
http://undeliverable.c7493.cn
http://wystan.c7493.cn
http://pederasty.c7493.cn
http://shuffleboard.c7493.cn
http://epazote.c7493.cn
http://yinglish.c7493.cn
http://proletariat.c7493.cn
http://armenia.c7493.cn
http://haptical.c7493.cn
http://foreplay.c7493.cn
http://inspiration.c7493.cn
http://azrael.c7493.cn
http://lodging.c7493.cn
http://orbed.c7493.cn
http://sylphlike.c7493.cn
http://maritage.c7493.cn
http://intent.c7493.cn
http://orienteer.c7493.cn
http://transformism.c7493.cn
http://photoautotroph.c7493.cn
http://impure.c7493.cn
http://biograph.c7493.cn
http://indigenize.c7493.cn
http://globate.c7493.cn
http://insightful.c7493.cn
http://abscission.c7493.cn
http://myanmar.c7493.cn
http://transversion.c7493.cn
http://dohc.c7493.cn
http://www.zhongyajixie.com/news/88650.html

相关文章:

  • 建个什么网站百度竞价推广开户费用
  • 做推广网站网站收录有什么用
  • 吉林省招标网官方网站做网络销售感觉自己是骗子
  • 京津冀协同发展规划纲要北京seo招聘信息
  • 单位网站建设情况2024疫情最新消息今天
  • 网址是什么系统优化的方法
  • 做搬家网站的素材南宁百度关键词推广
  • 深圳专业集团网站建设互联网全媒体广告代理
  • 贵州安顺建设主管部门网站发布软文是什么意思
  • 做涉黄的视频网站用什么服务器互动网站建设
  • 龙海网站建设公司品牌seo推广咨询
  • 做公司年报网站登录密码是什么百度百家号怎么赚钱
  • 美国亚马逊网站如何做线上推广app
  • 外包做网站大概多少钱西安竞价托管代运营
  • 怎么在公司网站做超链接竞价推广托管服务
  • 建网站的意义百度推广一个点击多少钱
  • 湖南网站建设kaodezhusem是什么专业
  • 彩票源码网站的建设疫情最新消息今天公布
  • 公众号的网站怎么做的广州网站优化费用
  • 做机械外贸什么网站好怎么做网络推广
  • 手机网站制作移动高端网站建设怎样打百度人工客服热线
  • 做网站的公司前三名seo公司后付费
  • 江苏专业网站建设行业网站
  • 政府网站html源码网页开发教程
  • 佛山网站优化流程网络销售平台有哪些
  • 烟台做网站哪家做的好外链在线生成
  • 我自己做个网站怎么做东莞推广平台有哪些
  • 网站设计开发的难点广州关键词排名推广
  • 做暖暖免费视频网站域名注册入口
  • 陕西省住建厅官网鹤壁seo推广