im trying to make a program that reads a text file in the format:
2
polygon 3
90 90
90 90
90 90
polyline 2
12 80
30 15
(not the real numbers obviously)
and have the program read how many things, what type, how many points for that type, etc and then draw them.
i finally got it to build with no errors, but i keep getting an error that says "debug assertion failed" when i try to debug it.
i can't figure out where i'm going wrong with this
here is my code:
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include "glut.h"
void main(int argc, char **argv)
{
printf("Blah blah blah \n");
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 150);
glutCreateWindow("Assignment 1");
FILE *in;
in = fopen("house.txt","r");
int number;
int x,y;
char string[16];
float r,g,b;
int polycount;
fscanf(in,"%d\n",&polycount);
for(int i=1;i<=polycount;++i)
{
fscanf(in,"%s%d\n",string,&number);
if((strcmp(string,"polygon"))==0)
{
for(int j=1;j<=number;++j)
{
fscanf(in,"%d%d\n",&x,&y);
glBegin(GL_LINE_LOOP);
glVertex2i(x,y);
}
glEnd();
glFlush();
}
else if((strcmp(string,"polyline"))==0)
{
for(int j=1;j<=number;++j)
{
fscanf(in,"%d%d\n",&x,&y);
glBegin(GL_LINE_STRIP);
glVertex2i(x,y);
}
glEnd();
glFlush();
}
}
printf("press any key to quit");
getchar();
}
i would greatly appreciate any insight as to what the problem may be. thanks!