1. 程式人生 > >【設計開發】 Linux C文件創建Open函數

【設計開發】 Linux C文件創建Open函數

include == code pan lin his class trunc types.h

#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"); } }

【設計開發】 Linux C文件創建Open函數