I am stuck at this for 2 days since I am so new to C++.I want to use this function to convert from CString Array to Int Array but I dont know how it could be done. Is there any suggestions, Thanks in Advance !
Here are my code:
void CCalculationBasicDlg::StringToIntegerArr(const CStringArray& arFields)
{
int length = arFields.GetSize();
int* arNum = new int[length];
int tmp = 0;
for (int i = 0; i < length; i++)
{
tmp = _tstof(arFields[i]);
arNum[i] = tmp;
}
}
// button to test function
void CCalculationBasicDlg::OnBnClickedBtnResult()
{
UpdateData(TRUE);
CString str_1, strDelimiters;
CStringArray arFields1;
edit_number_one.GetWindowText(str_1);
m_ctrlDelimiters.GetWindowText(strDelimiters);
// take String 1 and store in arFields1
MyTokenizer(str_1, strDelimiters, arFields1);
StringToIntegerArr(arFields1);
// Can I put a breakpoint to test the integer array
UpdateData(FALSE);
}