I'm having a problem with an exception that keeps coming up when I try to run my program. Is there anything I can do to my code to get rid of this My code compiles fine.
First-chance exception at 0x695bffe0 in proj_text_spheres.exe: 0xC0000005: Access violation reading location 0x00454001.
Unhandled exception at 0x695bffe0 in proj_text_spheres.exe: 0xC0000005: Access violation reading location 0x00454001.
I suspect the source of my problem has to do with a call to fclose.
Here's part of my code (I writing an OpenGL program that maps a texture to a sphere):
void read_fractal1_image(void)
{
errno_t err;
int i,j;
FILE *f1_file;
if((err = fopen_s(&f1_file, "pics/fractal1.bmp", "r+")) != 0)
{printf("File could not be opened!\n");}
else
{fseek(f1_file,1078,0);
for(i=0;i<array_size;i++)
{
for(j=0;j<array_size;j++)
{fractal1_image
}
fclose(f1_file);}
}
Thanks in advance!

Having Trouble with an exception
Pittsburgh
Have you tried stepping through your code in a debugger
A debugger is an excellent tool for tracking down issues like this.
Saurav Kr. Basu
Zoiner Tejada
At a call to:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, array_size, array_size,
0, GL_RGBA, GL_UNSIGNED_BYTE, fractal1_image);
which somehow calls int __cdecl _close in close.c
and the exception occurs at this line:
__finally {
_unlock_fh(fh); /* unlock the file */
}
Unhandled exception at 0x04a24ab9 in proj_text_spheres.exe: 0xC0000005: Access violation reading location 0x00454000.
Any way I can resolve this
URLmon
int __cdecl _flush (
FILE *str
)
{
REG1 FILE *stream;
REG2 int rc = 0; /* assume good return */
REG3 int nchar;
/* Init pointer to stream */
stream = str;
if ((stream->_flag & (_IOREAD | _IOWRT)) == _IOWRT && bigbuf(stream)
&& (nchar = (int)(stream->_ptr - stream->_base)) > 0)
{
if ( _write(_fileno(stream), stream->_base, nchar) == nchar ) {
/* if this is a read/write file, clear _IOWRT so that
* next operation can be a read
apparently when I call glTexImage2D* i have a problem accessing the texture file