设计开发 Linux C文件创建Open函数

Posted Digital-World

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了设计开发 Linux C文件创建Open函数相关的知识,希望对你有一定的参考价值。

 

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

 

int main(int argc, char *argv[]) 
{
    int i ;
    int fd ;
    
    char wbuf[] = "This is write file test!";
    
    printf("hello, world!
");

    fd=open("test.v",O_WRONLY | O_CREAT | O_TRUNC,0600);
    
    if(fd == -1)
    {
       printf("Open Failed!
");
    }
    else
    {
       printf("Open Success!
");
    }

    if(write(fd,wbuf,strlen(wbuf)) != -1)
    {
       printf("Write Success!
");
    }
}

 

以上是关于设计开发 Linux C文件创建Open函数的主要内容,如果未能解决你的问题,请参考以下文章