First-chance exception in Prac2.exe: 0xC0000005: Access Violation

Am getting "First-chance exception in Prac2.exe: 0xC0000005: Access Violation."
on the line “temp = the_object->vertices_camera[t2].x;”. I changed t2 to a
proper integer (like 0) and the debugger passes it ok, but still stops at the
other [t2] lines. Does anyone know what is wrong here?

/* Draw patches /
for ( p=glob_1; p<=glob_2; p++ ) { // Patch indexes
for ( i=0; i<4; i++) { // Vertex indexes
for ( j=0; j<4; j++) {
t1 = i
4 + j;
t2 = (int)(the_object->patches[p].vertex_list[t1])-1;
temp = the_object->vertices_camera[t2].x;
xyz_patch[i][j][0] = temp;
xyz_patch[i][j][1] = the_object->vertices_camera[t2].y;
xyz_patch[i][j][2] = the_object->vertices_camera[t2].z;
}
}

SOME BACKGROUND:

Am trying to convert my code from my graphics practical on displaying bezier
surfaces to using SDL. All I needed to do was make my code use SDL draw pixel
function, etc. That code snippet above worked ok before in linux. Could it be
Visual C++ 6.0 stuff doing? Is there something I need to know about when
working with Windows memory?

Have you checked that the value of t2 really is valid value?On Wednesday 25 December 2002 05:06, K Cheng wrote:

Am getting “First-chance exception in Prac2.exe: 0xC0000005: Access
Violation.” on the line “temp = the_object->vertices_camera[t2].x;”.
I changed t2 to a proper integer (like 0) and the debugger passes it
ok, but still stops at the other [t2] lines. Does anyone know what is
wrong here?

/* Draw patches /
for ( p=glob_1; p<=glob_2; p++ ) { // Patch indexes
for ( i=0; i<4; i++) { // Vertex indexes
for ( j=0; j<4; j++) {
t1 = i
4 + j;
t2 = (int)(the_object->patches[p].vertex_list[t1])-1;
temp = the_object->vertices_camera[t2].x;
xyz_patch[i][j][0] = temp;
xyz_patch[i][j][1] = the_object->vertices_camera[t2].y;
xyz_patch[i][j][2] = the_object->vertices_camera[t2].z;
}
}