2019-10-30

1.exit为C++的退出函数,声明于stdlib.h中,对于C++其标准的头文件为cstdlib,声明为
void exit(int value);
exit的功能为,退出当前运行的程序,并将参数value返回给主调进程。
在main中return v;的效果 与exit(v);相同。
exit(1)和exit(-1)
是分别返回1和-1到主调程序。
exit(0)则是返回0。
exit(0)表示程序正常退出,非0表示非正常退出
(在c中同样在头文件include<stdlib.h>中)
2.复习前两天的内容

include<stdio.h>

include<malloc.h>

include<string.h>

struct Student{
int std;
char a[200];
int age;
};
struct Student*creatstruct(void);
void showstruct(struct Student *psp);
int main(void){
struct Student sp;
sp=creatstruct();
showstruct(sp);
return 0;
}
struct Student
creatstruct(void){
struct Student *p=(struct Studeng *)malloc(sizeof(struct Student *));
p->std=88;
strcpy(p->a,"zhangsan");
p->age=99;
return p;
}
void showstruct(struct Student *psp){
printf("%d %s %d",psp->std,psp->a,psp->age);
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容