Odd one, this...
Function below loads an .ini file (attached). The stared line gives:
FATAL RUN-TIME ERROR: "Ana.c", line 81, col 21, thread id 0x000009A4:
Dereference of out-of-bounds pointer: 1712154706 bytes (428038676
elements) before start of array.
If commented-out, the popup fires correctly, with card_count correctly incrementing from 0 to 3.
There is nothing else in this program - What am I doing wrong?
#define NUM_CHANNELS 32
#define CHANNELS_PER_ROUTER 8
short SPC_load(void)
{
char SPCtiming_Path[MAX_PATHNAME_LEN] = "c:\\data\\spc_timing.ini";
int SPC_fh;
float CFD_LimitLow[NUM_CHANNELS/CHANNELS_PER_ROUTER];
float CFD_ZeroCross[NUM_CHANNELS/CHANNELS_PER_ROUTER];
float Offset[NUM_CHANNELS/CHANNELS_PER_ROUTER];
char strLine[100], strVal[10];
int intLinelen, card_count = -1;
float fltVal;
SPC_fh = OpenFile (SPCtiming_Path, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII)
while ((intLinelen=ReadLine (SPC_fh, strLine, -1))>-1)
{
if ( (intLinelen>3) && !(strLine[0]==*";") )
{
StringLowerCase(strLine);
if (strstr (strLine, "spc"))
{
card_count++;
}
if (strstr (strLine, "cfd_ll"))
{
CopyString(strVal,0,strLine,7,-1);
fltVal = ceil(100 * atof(strVal))/100;
CFD_LimitLow[card_count] = fltVal;
}
if (strstr (strLine, "cfd_zc"))
{
CopyString(strVal,0,strLine,7,-1);
fltVal = ceil(100 * atof(strVal))/100;
******* CFD_ZeroCross[card_count] = fltVal; *******
sprintf(strLine,"%d",card_count);
MessagePopup("Error",strLine);
}
if (strstr (strLine, "tac_off"))
{
CopyString(strVal,0,strLine,8,-1);
fltVal = ceil(100 * atof(strVal))/100;
Offset[card_count] = fltVal;
}
}
}
CloseFile (SPC_fh);
return 0;
}
Message Edited by Pythonist on 05-25-2006 09:22 AM
Message Edited by Pythonist on 05-25-2006 09:22 AM
__________________________________________
The world is full of exciting challenges,
brilliantly disguised as insoluble problems.