Access Violation / Problem with Memory Read
When not in debug mode, the code runs without error but no data is printed to the file. I am getting this error in debug: "Unhandled exception in file.exe: 0xC0000005: Access Violation.
When I step through it the errors seems to occur during MEMCPY.ASM.
Here is the code with the error line highlighted:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct preRec1 {
char ESTIMATE_NUMBER1[4];
char PAGE_NUMBER1[4];
char PROC_TYPE1[3];
};
struct preRec1a{
char X1[1];
};
struct preRec1b{
char ESTIMATE_NUMBER2[4];
char PAGE_NUMBER2[4];
char PROC_TYPE2[2];
char X2[8];
char PRIORITY[2];
char SALES_TAX[2];
};
struct Rec1 {
char ESTIMATE_NUMBER1[5];
char PAGE_NUMBER1[5];
char PROC_TYPE1[3];
};
struct Rec1a{
char X1[1];
};
struct Rec1b{
char ESTIMATE_NUMBER2[5];
char PAGE_NUMBER2[5];
char PROC_TYPE2[3];
char X2[9];
char PRIORITY[3];
char SALES_TAX[2];
};
void main(void)
{
FILE *f, *f2, *f3; // *f4, *f5;
struct preRec1 pr1;
struct preRec1a pr1a;
struct preRec1b pr1b;
struct Rec1 r1;
struct Rec1a r1a;
struct Rec1b r1b;
f = fopen("ESTINDEX", "rb");
f2 = fopen("ESTINDEX_R1_OUT", "wb");
f3 = fopen("ESTINDEX_R2_OUT", "wb");
memset(&r1, 0x0, sizeof(r1));
while (fread(&pr1, sizeof(struct preRec1), 22, f))
{
memcpy(&r1.ESTIMATE_NUMBER1, &pr1.ESTIMATE_NUMBER1, sizeof(r1.ESTIMATE_NUMBER1));
memcpy(&r1.PAGE_NUMBER1, &pr1.PAGE_NUMBER1, sizeof(r1.PAGE_NUMBER1));
memcpy(&r1.PROC_TYPE1, &pr1.PROC_TYPE1, sizeof(r1.PROC_TYPE1));
fprintf(f2, "%s|", r1.ESTIMATE_NUMBER1);
fprintf(f2, "%s|", r1.PAGE_NUMBER1);
fprintf(f2, "%s\n", r1.PROC_TYPE1);
}
fclose(f);
printf("All Done\n");
}
Once the error line is hit I am taken to the disassembly: 393335FF ?.
What does this mean?
Thanks, cj

