write

write_3分词条

目录 [隐藏]

write 函数名称

 
函数名:write

write 基本功能

 
写到一文件

write 用法示例

 
int write(int handel, void *buf, int nbyte);
程序例:

#include#include
#include
#include
#include
#include

int main(void)
{
int handle;
char string[40];
int length, res;

/*
Create a file named "TEST.$$$" in the current directory and write
a string to it. If "TEST.$$$" already exists, it will be overwritten.
*/

if ((handle = open("TEST.$$$", O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE)) == -1)
{
printf("Error opening file.\n");
exit(1);
}

strcpy(string, "Hello, world!\n");
length = strlen(string);

if ((res = write(handle, string, length)) != length)
{
printf("Error writing to the file.\n");
exit(1);
}
printf("Wrote %d bytes to the file.\n", res);

close(handle);
return 0;
}

struct xfcb {

char xfcb_flag; /* Contains 0xff to indicate xfcb */

char xfcb_resv[5]; /* Reserved for DOS */

char xfcb_attr; /* Search attribute */

struct fcb xfcb_fcb; /* The standard fcb */

};

附图

上传图片 

互动百科的词条(含所附图片)系由网友上传,如果涉嫌侵权,请与客服联系,我们将按照法律之相关规定及时进行处理。如需转载,请注明来源于www.hudong.com

被引用: 本词条已被如下媒体引用 我来补充
开放分类: 我来补充

讨论区

更多>>

编辑者

共1人协作

相关词条

plascal教程
电磁场的泛函法
asp
OLLYDBG
单元测试
anaconda
DLL
数组
勒贝格积分
溢出
更多

Copyright © 2005-2009 hudong.com Ltd. All Rights Reserved. 互动在线 版权所有