试图编写.ply解析器以在OpenGL中使用.ply模型。C++读取文件时出现未处理的异常
尝试开始读取.ply文件并将其写出所有行。 我的程序做到这一点,但是当它打印出的最后一行我得到未处理的异常:在PLY parser.exe在0x62aad540(msvcr100d.dll)
未处理的异常:0000005:访问冲突读取位置00000000。
这是我的代码:
#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;
}
这可能是我的代码中愚蠢的错误,但是这将是巨大的,如果有人能找到这个错误导致此。
但是你根本没有使用''。 –
Seagull
2012-03-01 20:33:34