一个自己创建的随笔

’ #include <stdio.h>
’ #include <sys/types.h>
’ #include <sys/stat.h>
’ #include <fcntl.h>
‘ #include <unistd.h>
’ #include <string.h>

int main(int argc,char *argv[])
{

int fd=open(argv[1],O_WRONLY | O_TRUNC);
if(fd==-1)
{
    perror("file open failure\r\n");
    return 0;
}
char buf[20]={0};

// scanf("%s",buf);
read(0, buf, 19);
int ret=write(fd, buf,strlen(buf));
if(ret==-1)
{
perror("file write failure\r\n");
return 0;
}
close(fd);

return 0;

}

posted @ 2022-01-05 20:38  codebuilder  阅读(54)  评论(0编辑  收藏  举报