int do_openFile(void)
{
char *p ; /* pointer to outFileName */
char *m ; /* pointer to report date */
char *mon; /* month number in report date */
/* get output file name */
m = pk->CNCRptdate;
m += 2;
strncpy(mon, m, 2);
p = outFileName ;
strcpy(p, pi->CNDExtransit);
p += 5;
strcpy(p, monTab[atoi(mon)]);
p += 3;
strcpy(p, ".");
p += 1;
strcpy(p, "TXT");
/* Open a new file for writing, if file exists, its contents are destroyed
*/
if ((outfile = fopen(outFileName, "w")) == NULL)
{
printf (" \r");
printf ("fopen failed\n");
printf ("Please hit 'PRINT SCREEN' and then hit ENTER to abort...\n");
getch();
return (0);
};
}
Issue: When the control hits the first strncpy() function, it throws "Unhandled exception at 0x00401acd in ICRSEX2B.exe: 0xC0000005: Access violation writing location 0x0040258f."
Pls let me know if any other information is required.