调试断言失败。 nullptr

时间:2016-07-13 07:17:49

标签: c++

我开始编程,我正在使用Visual Studio。我有一个简单的程序,几天前工作,但在使用另一个项目后,它返回一个错误:

'Project1.exe' (Win32): Loaded 'B:\Mis Documentos\Documents\Visual Studio 2015\Projects\Project1\Debug\Project1.exe'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-timezone-l1-1-0.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-file-l2-1-0.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-localization-l1-2-0.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-synch-l1-2-0.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-processthreads-l1-1-1.dll'. Symbols loaded.
'Project1.exe' (Win32): Loaded 'C:\Windows\System32\api-ms-win-core-file-l1-2-0.dll'. Symbols loaded.
Debug Assertion Failed!

Program: ...ments\Visual Studio 2015\Projects\Project1\Debug\Project1.exe
File: minkernel\crts\ucrt\src\appcrt\stdio\output.cpp
Line: 31

Expression: stream != nullptr

For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.

但是我无法编译它,它返回给我this error。这是日志:

stream.foreachRDD(rdd => {
  rdd.foreach(record = > parseAVROToString(record))
})

2 个答案:

答案 0 :(得分:0)

您没有检查文件是否实际打开。您应该在调用fopen

后检查文件是否实际打开
FILE *A = NULL;
....
A = fopen("B:\\Mis Documentos\\Coding\\Test 200.txt", "wt");
//Check if file was actually opened
if(A) {
....
}

检查此功能的文档,例如here。您还应该初始化A变量,这是一个很好的做法。

答案 1 :(得分:0)

最后这是我的错,我没有创建文件夹" Coding"我想要的文件。我可以完成我现在想做的事情,但我看到如果我想在我的Google云端硬盘文件夹中创建该文件,有时候其他人也不会做。不知道为什么,也许是因为它连接到互联网?

无论如何,非常感谢你的快速帮助!