linux之creat函数解析
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
creat函数完全可以被open函数替代:
open(pathname, O_WRONLY | O_CREAT | O_TRUNC, mode);
[lingyun@localhost create]$ vim creat.c
+ creat.c/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: creat.c
* Description: This file
*
* Version: 1.0.0(07/28/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "07/28/2013 01:05:30 PM"
*
********************************************************************************/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PERM 0755
int main(void)
{
static char filename[] = "file.txt";
int fd;
fd = creat(filename,PERM);
if(fd < 0)
printf("[%s] create fail !!!\n",filename);
else
printf("[%s] open success !\n",filename);
exit(0);
}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~/apue/creat/creat.c[+] CWD: /usr/local/src/lingyun/apue/creat Line: 17/33:18
"create.c" 33L, 869C written
[lingyun@localhost creat]$ gcc creat.c
[lingyun@localhost creat]$ ./a.out
[file.txt] open success !
[lingyun@localhost creat]$ ls
a.out creat.c file.txt
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献11条内容
所有评论(0)