tatexit.c

来自「su 的源代码库」· C语言 代码 · 共 44 行

C
44
字号
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved.                       */#include	"sftest.h"/* test to see if files created in atexit functions work ok */void ae(){	Sfio_t*	f = sfopen(NIL(Sfio_t*), tstfile(0), "w");	if(!f)		terror("Can't create file");	if(sfwrite(f,"1234\n",5) != 5)		terror("Can't write to file");}MAIN(){	Sfio_t* f;	if(argc <= 1) /* atexit function registered after some sfio access */	{	if(!(f = sfopen(NIL(Sfio_t*), tstfile(1), "w")) )			terror("Can't create file");		if(sfwrite(f,"1234\n",5) != 5)			terror("Can't write to file");		atexit(ae);		system(sfprints("%s 1",argv[0]));	}	else /* atexit function registered before some sfio access */	{	atexit(ae);		if(!(f = sfopen(NIL(Sfio_t*), tstfile(1), "w")) )			terror("Can't create file");		if(sfwrite(f,"1234\n",5) != 5)			terror("Can't write to file");	}	TSTEXIT(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?