Hallo,
I try to read a line of text in a file that looks like this: 10N11M12R
where N, M and R are numbers from 1 to 2000.
For 3-digit numbers, I extracted N, M and R in this way:
Code:
int count = 0;
int ch;
try
{
CStdioFile file(_T("temp.txt"), CFile::modeRead);
CString str,mainstr = _T("");
while(file.ReadString(str))
{
mainstr += str;
mainstr += _T("\n");
}
textBox2 ->SetWindowTextA(mainstr.Mid(3,3)); // N
textBox3 ->SetWindowTextA(mainstr.Mid(10,3)); // M
textBox4 ->SetWindowTextA(mainstr.Mid(17,3)); // R
}
catch(CException* e)//Catch by pointer as exceptions in MFC are crap
{
MessageBox(_T("Error - unable to open file"));
e->Delete();//Lame...very lame...but needed
}
How can parse this line and determine the number of digits that contains N, M and R?
Thanks,
Haris