【設計開發】 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!\n");

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

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM