my_create.c

来自「LINUX C编程实战这本书附带光盘的原代码」· C语言 代码 · 共 24 行

C
24
字号
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

int main()
{
	int fd;

	if ((fd = open("example_62.c", O_CREAT|O_EXCL, S_IRUSR| S_IWUSR)) == -1) {
	//if ((fd = creat("example_62.c", S_IRWXU)) == -1) {
		perror("open");
        //printf("open:%s    with errno:%d\n",strerror(errno),errno);
		exit(1);
	} else {
		printf("create file success\n");
	}
	
	close(fd);
	return 0;
}

⌨️ 快捷键说明

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