code:block 停建的glut项目,用fopen打不开文件

code::block 下建的glut项目,用fopen打不开文件
本帖最后由 wuanshi5 于 2013-06-28 12:59:58 编辑
void initialize() {
FILE* handle;

/* Seed random number generator */
srand( (unsigned)time( NULL ) );

        char file_path[] = "levels.dat";
/* Read level list */
if ( (handle = fopen( file_path,"r")) == NULL ) {
printf("Could not open board data file: levels.dat\n");
exit(1);
}
while (!feof(handle)) {
fscanf(handle, "%s", &levels[numLevels++]);
if (numLevels == 32) break; /* only load 32 levels */
}
fclose(handle);

/* Load 1st level */
loadLevel(levels[level]);

/* Setup OpenGL */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, windowWidth / windowHeight, 3, -3);
glMatrixMode(GL_MODELVIEW);

glClearColor(0.0, 0.0, 0.0, 0.0);
glPointSize(2.0);
}


这个函数里的fopen打不开levels.dat文件,测试过在控制台程序里能打开,也可以读取。
levels.dat也放在当前文件夹下了,可还是不行。
请大家帮忙分析分析。

用的编译器是code::block,建的工程是glut工程。之前把glut工程改成了freeglut工程。
glut opengl c fopen

------解决方案--------------------
应该是路径的问题,先用绝对路径试试看,比如"c:\\levels.dat"