Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Debugging 调试断言失败错误。don';我不知道如何处理指针_Debugging_Scanf_Null Pointer - Fatal编程技术网

Debugging 调试断言失败错误。don';我不知道如何处理指针

Debugging 调试断言失败错误。don';我不知道如何处理指针,debugging,scanf,null-pointer,Debugging,Scanf,Null Pointer,当我想运行我的代码时,我得到了这个错误 微软Visual C++运行库 调试断言失败 节目:…sual Studio 2013\\project1.exe 文件:f:\dd\vctools\crt\crtw32\stdio\fscanf.c 电话号码:52 表达式(流!=NULL) 有关如何。。。。。。废话 我检查了互联网,其他人通常会出现这种错误,因为他们的指针指向空位置,但我认为我的代码没有选项让我的指针指向空位置。如果指针是原因,我该怎么处理它? 谢谢你的帮助 #include <g

当我想运行我的代码时,我得到了这个错误

微软Visual C++运行库 调试断言失败

节目:…sual Studio 2013\\project1.exe 文件:f:\dd\vctools\crt\crtw32\stdio\fscanf.c 电话号码:52

表达式(流!=NULL)

有关如何。。。。。。废话

我检查了互联网,其他人通常会出现这种错误,因为他们的指针指向空位置,但我认为我的代码没有选项让我的指针指向空位置。如果指针是原因,我该怎么处理它? 谢谢你的帮助

#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);

}
#包括
#包括
浮点数ex,ey,ez;
未签名字符po;
void RenderScene(){
glutInitDisplayMode(GLUT_双精度| GLUT_RGBA | GL_深度_缓冲位);
glMatrixMode(GLU模型视图);
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、1.0f);
浮动顶点[531];
文件*数据;
int i;
fopen_s(&data,“teapot.dat”,“r”);
fscanf_s(数据,“%f”,顶点);
for(float*ptr=顶点;*ptr!=NULL;ptr++)
*ptr=*(ptr+1);
glEnableClientState(GL_顶点_数组);
glVertexPointer(3,GLU浮点,0,顶点);
gldrawArray(GL_多边形,0530);
glDisableClientState(GL_顶点_数组);
glutSwapBuffers();
}
无效设置RC(无效)
{
//设置清晰的颜色
glClearColor(0.0f、0.0f、1.0f、1.0f);
glEnable(GLU深度试验);
}
无效更改大小(GLsizei w、GLsizei h)
{
GLfloat aspectRatio;
//防止被零除
如果(h==0)
h=1;
//将视口设置为窗口尺寸
glViewport(0,0,w,h);
//重置坐标系
glMatrixMode(GL_投影);
glLoadIdentity();
//建立剪裁体积(左、右、下、上、近、远)
aspectRatio=(GLfloat)w/(GLfloat)h;
glMatrixMode(GLU模型视图);
glLoadIdentity();
如果(po=true)
gluPerspective(90.f,aspectRatio,10.f,200.f);
其他的
格洛托(-100.f,100.f,-100.f,100.f,-100.f,100.f);
}

也许您应该先检查
fopen_s()
是否成功,然后再盲目地将
data
的值传递给
fscanf_s()
…我这样做了,但没有任何改变:/