Hi
During writing a code, I need to define dynamic arrays several times, so I wrote the following simple function for defining a double 1D array:
/*----------------------------------------------------------------------------
Function for Difining 1-D Dynaimcs Arrays for Storing Double Values
------------------------------------------------------------------------------*/
double *allocation_1d_double(int size)
{
double *array;
if ( (array = (double *)malloc(size*sizeof(double)) ) == NULL )
{
printf("\nError, memory not allocated.\n");
exit(1);
}
return array;
}
The function works well for more than 20 calling but suddenly it gives the following error:
“Unhandled exception in a.exe: Access Violation"
I checked the code several times and I'm quite sure that error is happened in calling this function. If there was any problem in memory, I expected to receive memory error message but now, I don't know what is wrong with code. Would you please help me?