C语言程序问题,在VC++6.0中运行为什么总显示错误,如何改正

#include<string.h>#include<stdio.h>#include<errno.h>#include<dos.h>#include<io.h>intm... #include <string.h>
#include <stdio.h>
#include <errno.h>
#include <dos.h>
#include <io.h>
int main(void)
{
int handle;
char buf[11] = "0123456789";
/* attempt to create a file that doesn't already exist */
handle = creatnew("DUMMY.FIL", 0);
if (handle == -1)
printf("DUMMY.FIL already exists.\n");
else
{
printf("DUMMY.FIL successfully created.\n");
write(handle, buf, strlen(buf));
close(handle);
}
return 0;
}
展开
 我来答
kaixingui2012
2012-12-22 · TA获得超过4.2万个赞
知道大有可为答主
回答量:1.4万
采纳率:81%
帮助的人:6158万
展开全部
char buf[12] = "0123456789"; //因为你后面操作是按字符串操作:strlen()。因此,这里在定义时,数组长度应该至少比数据长度大1,给\0留个位置。strlen(buf)函数是按\0位置返回字符串长度的!
更多追问追答
追问
用VC++6.0运行,一直是这个错误,为什么呢

error C2065: 'creatnew' : undeclared identifier
追答
标准C中没有creatnew()这个函数,需要你自己去实现!
你不会是抄来的代码吧,没有抄全?!
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式