一个自己创建的随笔
’ #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;
}