文件I/O-006.没有文件时 创建新的,若有则APPEND打开
2016-09-28 22:33
239 查看
/* 若没有文件,则创建新文件,若有文件,则APPEND打开 笔记 循环打开同一个文件,每次都是不同的文件描述符,每次都有一个文件表项,指向同一个V节点表项 */ #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> int main(int argc,char const *argv[]) { int fd; int i; char tmp='a'; for(i=0;i<10;i++) { fd=open("test.txt",O_CREAT|O_RDWR|O_APPEND,0777); printf("%d %d\n",i,fd); write(fd,&tmp,1); tmp++; } } /* ./a.out 0 3 1 4 2 5 3 6 4 7 5 8 6 9 7 10 8 11 9 12 od -c test.txt 0000000 a b c d e f g h i j 0000012 */
相关文章推荐
- 打开图片,提示:该文件没有程序与之关联来执行该操作。请在控制面板的文件夹选项中创建关联
- 关于MMC不能打开文件C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQL Server Enterprise Manager.MSC可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版本创建。也可能你没有访问此文件的足够权限
- FTP 打开文件夹提示"该文件没有程序与之关联来执行该操作 请在控制面板的文件夹选项中创建关联
- 关于MMC不能打开文件C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQL Server Enterprise Manager.MSC可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版本创建。也可能你没有访问此文件的足够权限
- (转)如果“打开方式”里面没有想要的打开方式,怎样创建一种文件打开方式?
- MMC不能打开文件C:\WINDOWS\system32\devmgmt.msc。这可能是由于文件不存在,不是一个MMC控制台,或者用后来版本的MMC创建 。也可能是由于您没有访问此文件的足够权限
- 关于MMC不能打开文件C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQL Server Enterprise Manager.MSC可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版本创建。也可能你没有访问此文件的足够权限
- 在没有Word 2007的情况下如何编辑和打开.docx文件
- JSP下载文件,直接下载文件保存到本地,不直接打开,没有乱码
- 使用asp.net在硬盘上写(创建)文件时,提示没有相应的权限:
- 解决CD12"未能创建DOM文件,没有注册类别,校验MSXML4安装&
- 无法创建SSP,没有索引器,如何打开search服务
- [WPF Bug清单]之(3)——暗中创建文件的打开文件对话框
- 打开项目时提示如下错误:Visual Studio .NET 无法创建应用程序 。问题很可能是因为本地 Web 服务器上没有安装所需的组件
- VS2005 起始页 最近的项目中 没有打开/创建网站选项
- 文档创建,文件的打开, 保存
- tail: 无法打开“+2” 读取数据: 没有那个文件或目录
- 通过试验探索Access 2000/XP 数据库的最佳 NTFS 权限设置Microsoft Jet 数据库引擎打不开文件'D:\wwwroot\test\data\'。 它已经被别的用户以独占方式打开,或没有查看数据的权限。
- 用KMP打开视频文件出现"无法创建图表生成器"错误的解决办法
- 打开项目时提示如下错误:Visual Studio .NET 无法创建应用程序 。问题很可能是因为本地 Web 服务器上没有安装所需的组件