【发布时间】:2012-03-01 20:29:15
【问题描述】:
尝试编写 .ply 解析器以在 OpenGL 中使用 .ply 模型。
尝试开始读取 .ply 文件并写出它的所有行。 我的程序会这样做,但是当它打印出最后一行时,我得到未处理的异常:
PLY parser.exe 中 0x62aad540 (msvcr100d.dll) 处的未处理异常:0xC0000005:访问冲突读取位置 0x00000000。
这是我的代码:
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
using namespace std;
int main ()
{
char buffer[10000];
FILE * myFile;
myFile = fopen("walkman.ply", "r");
if(myFile != NULL)
{
while (!feof(myFile))
{
cout<<fgets(buffer, 10000, myFile);
}
fclose(myFile);
}
else
{
cout<<"file not found"<<endl;
}
system("pause");
return 0;
}
这可能是我的代码中的愚蠢错误,但如果有人能发现导致此错误的错误,那就太好了。
【问题讨论】:
-
但是你根本没有使用
<fstream>。