【设计开发】 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"); } }