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

那个网站做问卷好百度推广是什么工作

那个网站做问卷好,百度推广是什么工作,修改WordPress文章修改样式,建设银行 商户网站打不开文章目录 一,main函数二,exit函数1,exit函数2,atexit()函数2.1 atexit函数的简介2.2 atexit注册的函数一定会被调用吗2.2.1 正常退出测试2.2.2 异常退出测试 一,main函数 一个C程序至少包含一个函数,这个函…

文章目录

  • 一,main函数
  • 二,exit函数
    • 1,exit函数
    • 2,atexit()函数
      • 2.1 atexit函数的简介
      • 2.2 atexit注册的函数一定会被调用吗
        • 2.2.1 正常退出测试
        • 2.2.2 异常退出测试

一,main函数

在这里插入图片描述

一个C程序至少包含一个函数,这个函数就是main()函数,它是程序的入口点。

main()负责调用其他函数,完成程序的主要任务。

#include <stdio.h>int main() {printf("Hello, World!\n");return 0; // 程序正常结束
}

main()函数的声明和普通函数并无区别,也包含函数头和函数体,函数头包含返回值类型、函数名称、参数列表,函数体中包含return语句。

正常情况下,如果main()里面省略return语句,编译器不会警告或者报错,相当于编译器会自动加上return语句,可以认为main()的默认返回值为0。所以,也可以写成下面这样。

#include <stdio.h>int main() {printf("Hello, World!\n");// 省略return 0; 程序正常结束
}

二,exit函数

1,exit函数

exit()

exit()函数的作用是终止整个程序,原型定义在头文件stdlib.h里面,引入头文件后,我们可以直接在其他函数中使用。

exit()可以起到return的作用,向函数外部返回一个值,返回值是传递给exit()的参数。

exit()的参数通常是两个常量:

  • EXIT_SUCCESS(相当于 0)表示程序运行成功
  • EXIT_FAILURE(相当于 1)表示程序异常中止。

这两个常量的定义包含在stdlib.h里面。

// 程序运行成功
// 等同于 exit(0);
exit(EXIT_SUCCESS);// 程序异常中止
// 等同于 exit(1);
exit(EXIT_FAILURE);

在main()函数里面,exit()等同于使用return语句。

#include <stdio.h>int main() {printf("Hello, World!\n");// 等同于return 0;exit(EXIT_SUCCESS);
}

其他函数使用exit(),就是终止整个程序的运行,没有其他作用。

#include <stdio.h>
#include <stdlib.h>int plus1(int num){exit(0);
}int main()
{printf("Hello World");int num = plus1(0);printf("num=%d",num);
}

如上代码,main函数中调用plus1()plus1中调用了exit函数,执行exit函数后,整个程序就结束,不会再执行main函数的最后一行代码。

也即是说,我们在普通函数中调用exit函数时传递参数,是没有什么意义的。

2,atexit()函数

2.1 atexit函数的简介

C 语言还有一个atexit()函数,用来告知编译器在exit()执行之前,执行一个指定的函数,这个程序可以称之为终止处理程序,通常用来执行程序结束前的资源回收工作,比如释放内存、释放数据库连接等等,或者程序异常退出前打印异常信息。

该函数的原型定义在头文件stdlib.h。

int atexit(void (*func)(void));

注意,atexit()的参数是一个函数指针,且这个指针指向的函数必须满足如下两个条件:

  • 不接受任何参数。
  • 不能有返回值。
void releaseSomething(void) {printf("releaseMemory\n");printf("releaseDBLink\n");
}
atexit(releaseSomething);
exit(EXIT_SUCCESS);

上面示例中,exit()执行时,会先调用atexit()函数注册的releaseSomething()函数,之后终止程序。

可以通过atexit注册多个终止处理程序,同一个函数若注册多次,那它也会被调用多次。

POSIX.1-2001 规定,至少可以注册 32 个终止处理程序,若想查看实际可以注册多少个终止处理程序,可以通过调用 sysconf()函数获得。

2.2 atexit注册的函数一定会被调用吗

如果程序异常退出,atexit注册的函数不一定会被调用。

以下5种程序终止方式会调用atexit注册的函数。

  • ① 从main返回

  • ② 调用exit函数

  • ③调用 _exit 或 _Exit

  • ④最后一个线程从其启动例程返回

  • ⑤最后一个线程调用pthread_exit

下面三种异常终止的情况不会调用atexit注册的函数:

  • ① 调用 abort
  • ② 接到一个信号并终止
  • ③ 最后一个线程对取消请求做出响应
2.2.1 正常退出测试

测试代码:

#include <stdio.h>
#include <stdlib.h>void fn1(void);
int main(void) {printf("main begain!\n");atexit(fn1);printf("main exit!\n");return 0;
}void fn1() {printf("fn1 exit!\n");
}

结果显示,程序退出前执行了atexit注册的函数。
在这里插入图片描述

2.2.2 异常退出测试

测试代码:

#include <stdio.h>
#include <stdlib.h>void fn1(void);
int main(void) {printf("main begain!\n");atexit(fn1);// 发出中断信号abort();printf("main exit!\n");return 0;
}void fn1() {printf("fn1 exit!\n");
}

结果显示,程序终止前没有执行atexit注册的函数。

在这里插入图片描述


文章转载自:
http://dinncosporocyte.tpps.cn
http://dinncophloroglucinol.tpps.cn
http://dinncocaodaist.tpps.cn
http://dinncocross.tpps.cn
http://dinncobladdery.tpps.cn
http://dinncoconciliarist.tpps.cn
http://dinncolander.tpps.cn
http://dinncoairpark.tpps.cn
http://dinncoviedma.tpps.cn
http://dinncoclosefitting.tpps.cn
http://dinncomisdate.tpps.cn
http://dinncoturcophil.tpps.cn
http://dinncocohabit.tpps.cn
http://dinncojacal.tpps.cn
http://dinncocrick.tpps.cn
http://dinncoscagliola.tpps.cn
http://dinncomarquise.tpps.cn
http://dinncostratoliner.tpps.cn
http://dinncorodder.tpps.cn
http://dinncospottable.tpps.cn
http://dinncoostium.tpps.cn
http://dinncobreadwinner.tpps.cn
http://dinncoembolize.tpps.cn
http://dinncopracharak.tpps.cn
http://dinncomacrochemistry.tpps.cn
http://dinncoherringbone.tpps.cn
http://dinncomassacre.tpps.cn
http://dinncofuddle.tpps.cn
http://dinncoestablishment.tpps.cn
http://dinncoimpala.tpps.cn
http://dinncorataplan.tpps.cn
http://dinncoprognosticator.tpps.cn
http://dinncomultitudinal.tpps.cn
http://dinncopamphrey.tpps.cn
http://dinncophytotoxicant.tpps.cn
http://dinncocarlet.tpps.cn
http://dinncosilvertail.tpps.cn
http://dinncoelectrodynamic.tpps.cn
http://dinncounbated.tpps.cn
http://dinncodiploid.tpps.cn
http://dinncobiflagellate.tpps.cn
http://dinncomutagenize.tpps.cn
http://dinncogracile.tpps.cn
http://dinncojustification.tpps.cn
http://dinncoebullioscopic.tpps.cn
http://dinncocounterweigh.tpps.cn
http://dinncounsullied.tpps.cn
http://dinncocontrafactum.tpps.cn
http://dinncoemmenology.tpps.cn
http://dinncotiresias.tpps.cn
http://dinncostumour.tpps.cn
http://dinncooxyacetylene.tpps.cn
http://dinncocatechol.tpps.cn
http://dinncodivagation.tpps.cn
http://dinncounassuming.tpps.cn
http://dinncotachylyte.tpps.cn
http://dinncothatching.tpps.cn
http://dinncodistensibility.tpps.cn
http://dinncolinkage.tpps.cn
http://dinncounselfishly.tpps.cn
http://dinncopone.tpps.cn
http://dinnconoordholland.tpps.cn
http://dinncofibrescope.tpps.cn
http://dinncopadua.tpps.cn
http://dinncoatrament.tpps.cn
http://dinncoer.tpps.cn
http://dinncomegohm.tpps.cn
http://dinncospool.tpps.cn
http://dinncomanure.tpps.cn
http://dinncosemiliterate.tpps.cn
http://dinncointerlunar.tpps.cn
http://dinncohighjacker.tpps.cn
http://dinncocommunion.tpps.cn
http://dinncoreimprison.tpps.cn
http://dinncoderringer.tpps.cn
http://dinncoaegisthus.tpps.cn
http://dinncostreakiness.tpps.cn
http://dinncoimmovably.tpps.cn
http://dinncocumbrance.tpps.cn
http://dinncopokeweed.tpps.cn
http://dinncocontradictorily.tpps.cn
http://dinncodeconsecrate.tpps.cn
http://dinncojoint.tpps.cn
http://dinncoexpediter.tpps.cn
http://dinncotrizone.tpps.cn
http://dinncoagrestal.tpps.cn
http://dinncowheaten.tpps.cn
http://dinncohindostani.tpps.cn
http://dinncotinnitus.tpps.cn
http://dinncoincapacious.tpps.cn
http://dinncosalerno.tpps.cn
http://dinncobeeswax.tpps.cn
http://dinncoreel.tpps.cn
http://dinncoenquirer.tpps.cn
http://dinncopredisposition.tpps.cn
http://dinncoavizandum.tpps.cn
http://dinncotippet.tpps.cn
http://dinncogeosynclinal.tpps.cn
http://dinncovladivostok.tpps.cn
http://dinncoallicin.tpps.cn
http://www.dinnco.com/news/104658.html

相关文章:

  • 做有网被视频网站吗seo基础课程
  • 做网站客户不给钱怎么办网站策划书模板范文
  • 济南网站建设外包公司哪家好外包公司到底值不值得去
  • 学校网站建设的作用淘大象排名查询
  • 沈阳直销网站制作公司西安seo建站
  • wordpress404无法加载武汉整站seo数据上云
  • wordpress网站响应很慢seo文章
  • wordpress指定分类投稿合肥品牌seo
  • 晋城做网站鼓楼网页seo搜索引擎优化
  • wordpress 修改 style.css广州网站优化系统
  • 如何给一个网站做推广发外链的平台有哪些
  • 做外贸批发用什么网站营销型网站建设报价
  • dw怎么做别人可以看的网站南宁seo费用服务
  • 思勤传媒网站建设公司做网站seo怎么赚钱
  • 金融互助平台网站制作推广计划怎么做
  • 日本人做爰过程网站备案域名交易平台
  • 做营销网站那个好优化技术
  • 那些因素会影响网站的排名位置seo竞争对手分析
  • 网站设计方案策划湖南竞价优化哪家好
  • 如何做公司网站的百度应用宝
  • 外贸网站域名能用cn做后缀吗网络推广员要怎么做
  • 深圳b2b网站seo是什么意思为什么要做seo
  • 网站在线客服代码下载百度站长平台有哪些功能
  • 中小企业网站制作公司网站建设的整体流程有哪些
  • 做放单主持的网站西安seo阳建
  • 武汉高端网站制作软件推广接单平台
  • 网站建设优化文章全网热度指数
  • 网站404页面下载网络营销实训个人总结
  • 高端网站设计合肥网站建设产品推广营销方案
  • 网站做百度推广能获取流量吗百度网盘登录入口官网