全文预览

C函数浏览

上传者:业精于勤 |  格式:pdf  |  页数:84 |  大小:11182KB

文档介绍
writefint handel, void *buf, int nbyte);\rP\r#include <stdio.h>\r#include <stdlib.h>\r#include <fcntl.h>\r#include <sys\stat.h>\r#include <io.h>\r#include <string.h>\rint main(void)\r{\rint handle;\rchar string[40];\rint length, res;\r/*\rCreate a file named "TEST.$$$" in the current directory and\rwrite\ra string to it. If "TEST.$$$H already exists, it will be\roverwritten.\r*/\rif ((handle = open(SEST.$$$"TO_WRONLY | O_CREAT |\rO_TRUNC,\rSJREAD | SJWRITE)) ==-l)\r(\rprintff'Error opening file.\n")\rexit :\r)\rstrcpyfstring, "Hello, world!\n");\rlength = strlen(string);\rif ((res = writefhandle, string, length)) != length)\r(\rprintff'Error writing to the file.\n")\rexit :\r}\rprintff'Wrote %d bytes to the file.\n"z res);\rclose(handle);\rreturn 0;\r)

收藏

分享

举报
下载此文档