|
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
main ()
{
char name[8];
char buf[1024];
int a,b;
printf ("input content:");
gets (buf);
printf ("input file name:");
scanf ("%s", name);
open (name, O_WRONLY);
a = open (name, O_WRONLY);
write (a, buf,strlen(buf));
close (a);
}
以上程序运行后,向一个空文件,如aa,中输入一个自符串,`用ls看文件字节是增加了,但cat aa却显示不出内容,这是为何? |
|