在文本文件读取过程中的调试断言

Debug assertion during text file reading

本文关键字:调试 断言 过程中 读取 文本 文件      更新时间:2023-10-16

我正在尝试从文本文件中读取4个浮动变量,然后将它们放入函数中。

void Array::readFile()
{
ifstream myfile1("numbers.txt");
if (!myfile1.is_open()) {
    cout << "The file could not be opened";
}
else {
    while (myfile1.good())
    {
        double a, b, c, d;
        myfile1 >> a >> b >> c >> d;
        //addMethod(a, b, c, d));
    }
}
}

和textfile数据的示例:

-0.143562 0.187022 0.130935 0.001797

我遇到的问题是我的调试断言失败了!行之后的错误:

else {

错误:表达式:_block_type_is_valid(phead-> nblockuse)

现在,我什至无法在while循环内部测试代码,因为它在此之前就断开了。我是C 的新手,因此在此类错误中不经历。我的文本文件位于带有EXE文件的调试文件夹中。

这里有一些GIST:array.cpp:https://gist.github.com/anonynymous/f9a9942bced0096613bfarray.h:https://gist.github.com/anonymous/ce68c4fe94949413487697来源/主:https://gist.github.com/anonymous/7545C4598196501A69D8

Array的驱动器做到这一点:

delete this->sphereArray;

但是,构造函数(或其他任何地方)都没有任何初始化的。

此外,Array::sphereArray的定义是这样的:

sphere *sphereArray[sizeof(sphere)];

您不能delete。也许您想浏览该数组的元素并删除它们。但是它们也是一个非传统的。另外,我非常怀疑线条并不能做您认为的事情。声明一系列指针是他们指向的类型的长度是非常不寻常的。