[英]C++: fread() causing assertion error?
我有一个由fread()
引起的错误,它说:
File: f:\ dd\vctools\ crt_bld\ self_x86\ crt\ src\fread.c
Line: 102
Expression: (stream != NULL)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
我该怎么办? 我的程序中已经包含了<stdio.h>
。 我目前正在使用Visual C ++ MFC开发我的项目。
Expression: (stream != NULL)
解释了这一切。
您正在传递NULL
流以进行fread
,但您不应该这样做。
您是否已验证要发送给fread的FILE对象正确? 使用它之前,请尝试检查它是否为null。 还要检查有关断言的文档,这与是否包含#include的文件无关。 这是运行时错误。
函数fread()
将FILE*
作为参数:
size_t __cdecl fread(
void *buffer,
size_t elementSize,
size_t count,
FILE *stream
)
您要发送的FILE*
为NULL。 您应该调试程序,并找出原因。
通过打开计算机中的文件f:\\ dd\\vctools\\ crt_bld\\ self_x86\\ crt\\ src\\fread.c
并查看其在第102行上的工作,您可能会像在我以前一样找到此信息。
您是否尝试过消息的(Press Retry to debug the application)
部分。
如果进入调试器,则可能会到达assert()并检查调用堆栈以查找fread调用的来源。 然后找出为什么FILE *在那里为空! 也许fopen失败了?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.