Here is my code. There is no error when I compile it but when I run it the program fails. Can somebody help? Thanks.
Code:
void CCStringParserDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
int i,j = 0;
int startIndex = 0;
int endIndex = 0;
int charCount = 0;
double Values[4];
CString strValues[4];
// Loop to parse values from m_sValues CString variable and store to string array
do
{
// Find position of space character in string contained in m_sValues CString variable
endIndex = m_sValues.Find(' ',startIndex);
charCount = endIndex - startIndex;
// Store captured value to array element of type string
strValues[i] = m_sValues.Mid(startIndex,charCount);
startIndex = endIndex + 1;
i++;
}
while (endIndex != -1);
// Store string array to double array
for (j = 0; j = 3; j++)
{
Values[j] = strtod(strValues[j],NULL);
}
// Display message containing first captured value
MessageBox(strValues[0]);
CDialog::OnOK();
}