抛出错误Debug Assertion Failed!
2015-09-10 09:35
387 查看
出现这种情况很可能是使用了野指针,比如某个指针指向一个局部变量,而在该变量作用域外使用该指针引用了该对象。
Assertion 是断言,用于假定某个条件肯定会满足,在debug模式下,当该条件不满足时则发生阻塞而弹出该对话框;在release下会忽略断言。
我不知道具体原因,但是我找到了一种解决办法:选择Build→Clean,重新编译就可以了。
expression:stream !=NULL
如果fopen()后返回的是NULL;就不能调用fclose()了;
用fopen()获得的文件句柄不是NULL,那么就需要用fclose()来关闭它。如果是NULL则不需要
null就表示你打开文件失败了,根本都没有成功的访问文件,也就不存在对数据有什么损坏的可能。不需要关闭。
在定义FILE * fp 之后,fopen的用法是:
fp = fopen(filename,"w")。
而对于fopen_s来说,还得定义另外一个变量errno_t err,然后
err = fopen_s(&fp,filename,"w")。
返回值的话,对于fopen来说,打开文件成功的话返回文件指针(赋值给fp),打开失败则返回NULL值;对于fopen_s来说,打开文件成功返回0,失败返回非0。
在vs编程中,经常会有这样的警告:warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use_CRT_SECURE_NO_WARNINGS. See online help for details. 是因为 fopen_s比fopen多了溢出检测,更安全一些。
相关文章推荐
- [LeetCode] Container With Most Water
- FZU 2156 Climb Stairs
- NSSearchPathForDirectoriesInDomains用法
- Get the date of the days before today on AIX
- HDU 1789 Doing Homework again
- 使用GCE(Google Container Engine)体验容器云服务 (1)
- VMware Containers - VMware vSphere Integrated Containers
- 游戏人工智能开发之6种决策方法
- Ubuntu下出现su:authentication failure的解决办法
- 快速去除图标斜线水印
- dnsmasq+postfix+sasl+tls+dovecot(邮件服务器)
- traits:Traits技术学习笔记
- cocos2d智能指针 转自:http://blog.csdn.net/nxshow/article/details/44699409
- hdu 2686 Matrix / 3376 Matrix Again最大费用流
- Waiting for table metadata lock问题的解决
- 第24/24周 数据库维护(Database Maintenance)
- 1090. Highest Price in Supply Chain (25)
- IBM AIX6.1上安装OpenSSH手记
- 查看某一个点是否在某个多边形内 使用ST_Contains函数
- error LNK2001: unresolved external symbol _main解决办法