Freeglut crashes after scanf in W8.1 and VS2012

167 views Asked by At

I'm finishing a project for college in C using freeglut (2.8.1), GLEW 1.10.0, Visual Studio 2012 and Windows 8.1. It's nearly done but for some reason I can't read from console after something has been drawn.

For example, I draw something and then ask the user for a file to read, with new data to draw:

printf("File to read: ");
gets(fname);                 //with scanf the result is the same
printf("%s", fname);         //just for testing

This prints the correct file name to the command line, and it reads the file correctly, however, for some reason, before the new data is displayed the entire thing crashes with the following error:

Unhandled exception at 0x73D3FB6D (freeglut.dll) in CV_TP1.exe: 0xC0000005: Access violation writing location 0x000000D4.

If I remove the gets/scanf and hard-code the file name the program works correctly. The same if I try to read something before all the openGL initializations, right at the top of the main function.

0

There are 0 answers