网站建设与维护模拟一,举例描述该如何布局网站关键词,车载导航地图属于什么地图,发布网站的空间#x1f308;个人主页#xff1a;小田爱学编程 #x1f525; 系列专栏#xff1a;c语言从基础到进阶 #x1f3c6;#x1f3c6;关注博主#xff0c;随时获取更多关于c语言的优质内容#xff01;#x1f3c6;#x1f3c6; #x1f600;欢迎来到小田代码世界~ #x… 
个人主页小田爱学编程  系列专栏c语言从基础到进阶 关注博主随时获取更多关于c语言的优质内容 欢迎来到小田代码世界~  喜欢的小伙伴记得一键三连哦 ૮(˶ᵔ ᵕ ᵔ˶)ა 一.解决疑问 
二.转移表 
三.回调函数 四.qsort函数 1.排序整形数据 2.排序结构数据 
3.qsort模拟实现 
五.sizeof和strlen的对比 
六.注意 一.解决疑问 一次函数调用把0这个整数值强制类型转换成一个函数的地址这个函数没有参数返             回类型是void去调用0地址处的函数 signal是一个函数 signal函数的参数有2个第一个是int类型    第二个是函数指针类型该指针指向的函数参数是int返回类型是void signal函数的返回类型是这种类型的void(*)(int)函数指针 该指针指向的函数参数是int返回类型是void 
二.转移表 函数指针数组的用途转移表 
#define _CRT_SECURE_NO_WARNINGS 1/*实现一个计算器
这个计算器能够计算整数的加法、减法、乘法、除法| ^    ||*/
void menu()
{printf(******************************\n);printf(****  1. add     2. sub   ****\n);printf(****  3. mul     4. div   ****\n);printf(****  0. exit             ****\n);printf(******************************\n);
}int Add(int x, int y)
{return x  y;
}int Sub(int x, int y)
{return x - y;
}int Mul(int x, int y)
{return x * y;
}int Div(int x, int y)
{return x / y;
}int main()
{int input  0;int x  0;int y  0;int ret  0;do{menu();printf(请选择:);scanf(%d, input);switch (input){case 1:printf(请输入两个操作数:);scanf(%d %d, x, y);ret  Add(x, y);printf(%d\n, ret);break;case 2:printf(请输入两个操作数:);scanf(%d %d, x, y);ret  Sub(x, y);printf(%d\n, ret);break;case 3:printf(请输入两个操作数:);scanf(%d %d, x, y);ret  Mul(x, y);printf(%d\n, ret);break;case 4:printf(请输入两个操作数:);scanf(%d %d, x, y);ret  Div(x, y);printf(%d\n, ret);break;case 0:printf(退出计算器\n);break;default:printf(选择错误重新选择\n);break;}} while (input);return 0;
} 
三.回调函数 
回调函数就是⼀个通过函数指针调⽤的函数。 如果你把函数的指针地址作为参数传递给另⼀个函数当这个指针被⽤来调⽤其所指向的函数 时被调⽤的函数就是回调函数。回调函数不是由该函数的实现⽅直接调⽤⽽是在特定的事件或条件发⽣时由另外的⼀⽅调⽤的⽤于对该事件或条件进⾏响应。 四.qsort函数 1.排序整形数据 
#include stdio.h
//qosrt函数的使⽤者得实现⼀个⽐较函数
int int_cmp(const void * p1, const void * p2)
{
return (*( int *)p1 - *(int *) p2);
}
int main()
{
int arr[]  { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };
int i  0;
qsort(arr, sizeof(arr) / sizeof(arr[0]), sizeof (int), int_cmp);
for (i  0; i sizeof(arr) / sizeof(arr[0]); i)
{
printf( %d , arr[i]);
}
printf(\n);
return 0;
} 2.排序结构数据 struct Stu //学⽣
{
char name[20]; //名字
int age; //年龄
};
//假设按照年龄来⽐较
int cmp_stu_by_age(const void* e1, const void* e2)
{
return ((struct Stu*)e1)-age - ((struct Stu*)e2)-age;
}
//strcmp - 是库函数是专⻔⽤来⽐较两个字符串的⼤⼩的
//假设按照名字来⽐较
int cmp_stu_by_name(const void* e1, const void* e2)
{
return strcmp(((struct Stu*)e1)-name, ((struct Stu*)e2)-name);
}
//按照年龄来排序
void test2()
{
struct Stu s[]  { {zhangsan, 20}, {lisi, 30}, {wangwu, 15} };
int sz  sizeof(s) / sizeof(s[0]);
qsort(s, sz, sizeof(s[0]), cmp_stu_by_age);
}
//按照名字来排序
void test3()
{
struct Stu s[]  { {zhangsan, 20}, {lisi, 30}, {wangwu, 15} };
int sz  sizeof(s) / sizeof(s[0]);
qsort(s, sz, sizeof(s[0]), cmp_stu_by_name);
}
int main()
{
test2();
test3();
return 0;
} 
3.qsort模拟实现 
#include stdio.h int int_cmp(const void * p1, const void * p2)
{
return (*( int *)p1 - *(int *) p2);
}
void _swap(void *p1, void * p2, int size)
{
int i  0;
for (i  0; i size; i)
{
char tmp  *((char *)p1  i);
*(( char *)p1  i)  *((char *) p2  i);
*(( char *)p2  i)  tmp;
}
}
void bubble(void *base, int count , int size, int(*cmp )(void *, void *))
{
int i  0;
int j  0;
for (i  0; i count - 1; i)
{
for (j  0; jcount-i-1; j)
{
if (cmp ((char *) base  j*size , (char *)base  (j  1)*size)  0)
{
_swap(( char *)base  j*size, (char *)base  (j  1)*size, size);
}
}
}
}
int main()
{
int arr[]  { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };
int i  0;
bubble(arr, sizeof(arr) / sizeof(arr[0]), sizeof (int), int_cmp);
for (i  0; i sizeof(arr) / sizeof(arr[0]); i)
{
printf( %d , arr[i]);
}
printf(\n);
return 0; 
五.sizeof和strlen的对比 六.注意 
1. sizeof(数组名)这⾥的数组名表⽰整个数组计算的是整个数组的⼤⼩。 2. 数组名这⾥的数组名表⽰整个数组取出的是整个数组的地址。 3. 除此之外所有的数组名都表⽰⾸元素的地址 燃烧的指针终于完结散花喽如果想知道下次的内容请持续关注系列专栏c语言从基础     到进阶 
今天的分享到这里就结束啦如果觉得文章还不错的话可以三连支持一下您的支持就是我前进的动力 文章转载自: http://www.morning.smdnl.cn.gov.cn.smdnl.cn http://www.morning.qblcm.cn.gov.cn.qblcm.cn http://www.morning.tclqf.cn.gov.cn.tclqf.cn http://www.morning.xhlpn.cn.gov.cn.xhlpn.cn http://www.morning.byxs.cn.gov.cn.byxs.cn http://www.morning.xsetx.com.gov.cn.xsetx.com http://www.morning.wrlff.cn.gov.cn.wrlff.cn http://www.morning.sgnjg.cn.gov.cn.sgnjg.cn http://www.morning.sfwfk.cn.gov.cn.sfwfk.cn http://www.morning.pxrfm.cn.gov.cn.pxrfm.cn http://www.morning.sphft.cn.gov.cn.sphft.cn http://www.morning.wtcyz.cn.gov.cn.wtcyz.cn http://www.morning.qlrtd.cn.gov.cn.qlrtd.cn http://www.morning.burpgr.cn.gov.cn.burpgr.cn http://www.morning.wwklf.cn.gov.cn.wwklf.cn http://www.morning.ykklw.cn.gov.cn.ykklw.cn http://www.morning.ybgpk.cn.gov.cn.ybgpk.cn http://www.morning.clbsd.cn.gov.cn.clbsd.cn http://www.morning.ffydh.cn.gov.cn.ffydh.cn http://www.morning.lftpl.cn.gov.cn.lftpl.cn http://www.morning.skscy.cn.gov.cn.skscy.cn http://www.morning.fqcdh.cn.gov.cn.fqcdh.cn http://www.morning.ddfp.cn.gov.cn.ddfp.cn http://www.morning.wfpmt.cn.gov.cn.wfpmt.cn http://www.morning.pqsys.cn.gov.cn.pqsys.cn http://www.morning.xkjqg.cn.gov.cn.xkjqg.cn http://www.morning.fbxdp.cn.gov.cn.fbxdp.cn http://www.morning.crfyr.cn.gov.cn.crfyr.cn http://www.morning.pwzzk.cn.gov.cn.pwzzk.cn http://www.morning.rqqmd.cn.gov.cn.rqqmd.cn http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn http://www.morning.clndl.cn.gov.cn.clndl.cn http://www.morning.rglzy.cn.gov.cn.rglzy.cn http://www.morning.nmfwm.cn.gov.cn.nmfwm.cn http://www.morning.fbmzm.cn.gov.cn.fbmzm.cn http://www.morning.qnyf.cn.gov.cn.qnyf.cn http://www.morning.rmxk.cn.gov.cn.rmxk.cn http://www.morning.dbddm.cn.gov.cn.dbddm.cn http://www.morning.rfljb.cn.gov.cn.rfljb.cn http://www.morning.dfhkh.cn.gov.cn.dfhkh.cn http://www.morning.qpqwd.cn.gov.cn.qpqwd.cn http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.wsgyq.cn.gov.cn.wsgyq.cn http://www.morning.diuchai.com.gov.cn.diuchai.com http://www.morning.rjjjk.cn.gov.cn.rjjjk.cn http://www.morning.fpczq.cn.gov.cn.fpczq.cn http://www.morning.rkck.cn.gov.cn.rkck.cn http://www.morning.jspnx.cn.gov.cn.jspnx.cn http://www.morning.rnlx.cn.gov.cn.rnlx.cn http://www.morning.ltpph.cn.gov.cn.ltpph.cn http://www.morning.crkmm.cn.gov.cn.crkmm.cn http://www.morning.wnnlr.cn.gov.cn.wnnlr.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.lrplh.cn.gov.cn.lrplh.cn http://www.morning.pmrlt.cn.gov.cn.pmrlt.cn http://www.morning.qmfhh.cn.gov.cn.qmfhh.cn http://www.morning.wbrf.cn.gov.cn.wbrf.cn http://www.morning.pxlsh.cn.gov.cn.pxlsh.cn http://www.morning.nlgmr.cn.gov.cn.nlgmr.cn http://www.morning.rwpfb.cn.gov.cn.rwpfb.cn http://www.morning.sftrt.cn.gov.cn.sftrt.cn http://www.morning.zsrdp.cn.gov.cn.zsrdp.cn http://www.morning.inheatherskitchen.com.gov.cn.inheatherskitchen.com http://www.morning.tqrbl.cn.gov.cn.tqrbl.cn http://www.morning.hrpjx.cn.gov.cn.hrpjx.cn http://www.morning.qnbgh.cn.gov.cn.qnbgh.cn http://www.morning.fchkc.cn.gov.cn.fchkc.cn http://www.morning.hqllx.cn.gov.cn.hqllx.cn http://www.morning.lynmt.cn.gov.cn.lynmt.cn http://www.morning.hcwlq.cn.gov.cn.hcwlq.cn http://www.morning.kgphd.cn.gov.cn.kgphd.cn http://www.morning.hymmq.cn.gov.cn.hymmq.cn http://www.morning.sjwiki.com.gov.cn.sjwiki.com http://www.morning.nzlsm.cn.gov.cn.nzlsm.cn http://www.morning.ldsgm.cn.gov.cn.ldsgm.cn http://www.morning.wqrk.cn.gov.cn.wqrk.cn http://www.morning.mjctt.cn.gov.cn.mjctt.cn http://www.morning.ykmtz.cn.gov.cn.ykmtz.cn http://www.morning.tsnwf.cn.gov.cn.tsnwf.cn http://www.morning.yunease.com.gov.cn.yunease.com