您好,登錄后才能下訂單哦!
/*
#define FLAGS O_RDWR|O_APPEND
#define SIZE 80
#define FILENAME "/home/mrhe/hello"
int main(int argc, char argv[])
{
int count;
int fd;
char write_buf[SIZE];
const char pathname=FILENAME;
if((fd=open(pathname,FLAGS))==-1)//調(diào)用open函數(shù)打開文件
{
printf("error,open file failed!\n");
exit(1);
}
printf("OK,open file successful!\n");
printf("Begin write:\n");
gets(write_buf);
count=strlen(write_buf);
if(write(fd,write_buf,count)==-1)//要寫入文件的數(shù)據(jù)的字節(jié)數(shù)
{
printf("error,write file failed!\n");
exit(1);
}
printf("OK,write %d strings to file!\n",count);
return 0;
}
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。