首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

fopen函数a+模式创建文件失败,路径正确

2012-07-28 
fopen函数a+方式创建文件失败,路径正确系统:win2003r2跟进fopen函数以后失败在这一句代码上if ((stream

fopen函数a+方式创建文件失败,路径正确
系统:win2003r2 
跟进fopen函数以后失败在这一句代码上if ((stream = _getstream()) == NULL){return NULL}, 返回了NULL。
文件创建的路径是没有问题的。
什么原因 ?


[解决办法]
代码贴上来啊

[解决办法]
用别的方式打开现存的文件,也失败吗
[解决办法]
文件是空的?_getstream()是做什么的
[解决办法]
如果楼主确认路劲没有问题,那应该就是_getstream()这个函数有问题了,单步调试这个函数。
[解决办法]
1. 改成这样试试 。.\\AntiPlugin\\APLog\\%d-%d-%d\\记录.txt
2. 把路径里的中文去掉试试
[解决办法]
"a+"

Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it doesn’t exist.

When a file is opened with the "a" or "a+" access type, all write operations occur at the end of the file. The file pointer can be repositioned using fseek or rewind, but is always moved back to the end of the file before any write operation is carried out. Thus, existing data cannot be overwritten.

The "a" mode does not remove the EOF marker before appending to the file. After appending has occurred, the MS-DOS TYPE command only shows data up to the original EOF marker and not any data appended to the file. The "a+" mode does remove the EOF marker before appending to the file. After appending, the MS-DOS TYPE command shows all data in the file. The "a+" mode is required for appending to a stream file that is terminated with the CTRL+Z EOF marker.

When the "r+", "w+", or "a+" access type is specified, both reading and writing are allowed (the file is said to be open for “update”). However, when you switch between reading and writing, there must be an intervening fflush, fsetpos, fseek, or rewind operation. The current position can be specified for the fsetpos or fseek operation, if desired.

热点排行