当我想运行我的代码时,我收到此错误。
Microsoft Visual C ++运行时库 调试断言失败!
程序:... sual Studio 2013 \ ... \ project1.exe 文件:F:\ DD \ vctools \ CRT \ crtw32 \标准输入输出\ fscanf.c 行:52
Expression(stream!= NULL)
有关如何...... blah
的信息我检查了互联网,其他人通常会得到错误,因为他们的指针到了一个空位但我不认为我的代码有一个选项,我的指针去任何地方null。如果指针' s我应该怎么做呢? 任何帮助表示感谢。
#include <glut.h>
#include<stdio.h>
float ex, ey, ez;
unsigned char po;
void RenderScene(){
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
ex = 1.0f;
ey = 1.0f;
ex = 1.0f;
gluLookAt(ex, ey, ez, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
float vertices[531];
FILE *data;
int i;
fopen_s(&data, "teapot.dat", "r");
fscanf_s(data,"%f",vertices);
for (float *ptr = vertices; *ptr != NULL; ptr++)
*ptr = *(ptr + 1);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_POLYGON,0 , 530);
glDisableClientState(GL_VERTEX_ARRAY);
glutSwapBuffers();
}
void SetupRC(void)
{
// setup clear color
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glEnable(GL_DEPTH_TEST);
}
void ChangeSize(GLsizei w, GLsizei h)
{
GLfloat aspectRatio;
// Prevent a divide by zero
if (h == 0)
h = 1;
// Set Viewport to window dimensions
glViewport(0, 0, w, h);
// Reset coordinate system
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Establish clipping volume (left, right, bottom, top, near, far)
aspectRatio = (GLfloat)w / (GLfloat)h;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
if (po=true)
gluPerspective(90.f, aspectRatio, 10.f, 200.f);
else
glOrtho(-100.f, 100.f, -100.f, 100.f, -100.f, 100.f);
}