ciao.
ho implementato la seguente funzione :
chemi ritorna il primo blocco solo numerico della stringa passata.
come blocco intendo separato da spazi all' ini zio e alla fine cosi':
aaa aaa a 123
ritorna 123
12a ad 44 safd
ritorna 44 ecc...
1qqq a2d 2a44 15 sfd
ritorna 15
codice:
CString CTypicalSectionBase::ReturnFirstNumericWholeWord(CString strName)
{
bool bMatched = true;
CString strFirstOcc = "";
int pos = 0;
for(int i = 0;(strFirstOcc = strName.Tokenize(" ",pos)) != "";i++)
{
bMatched = true;
char* buffer = strFirstOcc.GetBuffer();
for(int j = 0; j < sizeof(buffer);j++)
{
char c= buffer[j];
if(!isdigit(c) )
{
bMatched = false;
break;
}
}
if(bMatched)
return strFirstOcc;
}
return "";
}
il problema è che a questa riga:
char c= buffer[j];
if(!isdigit(c) )// c == 0 ma entra nell if. potrebbe essere il terminatore?
{
bMatched = false;
break;
}
}
c == 0 ma entra nell if. potrebbe essere il terminatore?
come posso risolvere?
grazie.