正文

创建一个新文件或重写一个已存在的文件2006-05-08 18:06:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/guxingxia/13726.html

分享到:

函数名: _creat  creat 功  能: 创建一个新文件或重写一个已存在的文件 用  法: int creat (const char *filename, int permiss); 程序例: #include <sys\stat.h> #include <string.h> #include <fcntl.h> #include <io.h> int main(void) {    int handle;    char buf[11] = "0123456789";    /* change the default file mode from text to binary */    _fmode = O_BINARY;    /* create a binary file for reading and writing */    handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE);    /* write 10 bytes to the file */    write(handle, buf, strlen(buf));    /* close the file */    close(handle);    return 0; }

阅读(1731) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册