【发布时间】:2013-07-24 12:23:08
【问题描述】:
我正在尝试将缓冲区输出到位于我的桌面的文件“z.txt”中。我正在使用 win32 (visual c++) 我这样做的语法是 -
memcpy(HtmlFileContents,&Buffer[location],HtmlFileLength);//i have the contents in HtmlFileContents
//which i have to display in the file "z.txt"
FILE *stream ;
errno_t err;
err=fopen_s(&stream, "C:\\Users\\sshekha\\Desktop\\z.txt","w");//err gives error 13
// when in write mode but when in read mode it opens the file
if( err == 0 )
{
MessageBox(m_hwndPreview,L" the file is opened ",L"BTN WND",MB_ICONINFORMATION);
}
else
{
MessageBox(m_hwndPreview,L" the file is not opened ",L"BTN WND",MB_ICONINFORMATION);
}
谁能告诉我为什么这样做???
【问题讨论】:
-
你能描述一下它做错了什么吗?
-
您实际上在哪里写入文件的输出?
-
Joachim 现在我只是打开它,但即使它没有打开它,并且 eb=ven 如果我把它设置为读取模式,它会给 dialodbox 提到“文件已打开”但是当我在调试时看到它有价值流 = 0x000000005c5c76f0 {_ptr=0x0000000000000000
_cnt=0 _base=0x0000000000000000 ...} -
然后它是打开的,你可以写入文件。不要过多阅读
stream结构中的值,因为它应该是一个“黑匣子”。 -
不,但这些值是当我输入“r”而不是“w”时。我的意思是在读取模式下它打开文件但不是在写入模式下(错误在写入模式下调试时给出 13,但在读取模式下给出 0)
标签: c++ visual-c++ fopen file-handling