#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"); } }
原文:https://www.cnblogs.com/digital-wei/p/9404377.html