C语言 <stdlib.h> abort 函数 描述 C库函数void abort(void)终止程序执行,并直接从调用位置发出。 声明 以下是abort函数的声明。 void abort(void) 复制 参数 没有参数。 返回值 此函数不返回任何值。 示例 以下示例显示abort函数的用法- #include <stdio.h> #include <stdlib.h> int main () { FILE *fp; printf("Going to open nofile.txt\n"); fp = fopen( "nofile.txt","r" ); if(fp == NULL) { printf("Going to abort the program\n"); abort(); } printf("Going to close nofile.txt\n"); fclose(fp); return(0); } 复制尝试一下 让我们编译并运行上面的程序,它将产生以下结果- String = jc2182, Address = 355090448 String = cainiaoya.com, Address = 355090448 复制 返回stdlib.h头文件