#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
/******************************
*file:close.c
*author:QG
*time:2015-05-10
*note:
********************************/
int main()
{
char *pt = "./123.txt";
int a = 0;
int b = 0;
a = open(pt,O_WRONLY);
if(a < 0)
{
printf("open file is fail!\n");
}
else
{
printf("open file is success,descriptor is %d!\n",a);
}
/**************************
*func:int close(int fd);
*parametre: fd is the file's descriptor which will be closed!
*return:close() returns zero on success, on error ,-1 is returned.
*function:
****************************/
b = close(a);
if(b == 0)
{
printf("close file is success!\n");
}
else
{
printf("close file is fail!\n");
}
return 0;
}
系统调用3--close
最新推荐文章于 2023-04-12 20:41:54 发布