How do know if there is one or more "." in a string.
If there is any "." then I perform certain action, and If there is non then I do something else
Printable View
How do know if there is one or more "." in a string.
If there is any "." then I perform certain action, and If there is non then I do something else
Code:for (char*i=string;*i;++i)
if (*i='i')
;//cetain action
else
;//something else
Thanks man!:D
*cough*Quote:
Originally posted by kedaman
Code:for (char*i=string;*i;++i)
if (*i='i')
;//cetain action
else
;//something else
Code:if(*i == 'i')
ooops
or using strstr function
PHP Code:char *Source = new char[10];
char *Search = new char[1];
char *p1=0;
char *tmp = new char[30];
strcpy(Source, "abcdef.ghi");
strcpy(Search, ".");
p1 = strstr(Source, Search);
if (p1 != NULL)
{
sprintf(tmp, "Dot found at address %ld", &p1);
MessageBox(hDlg, tmp, "Search", MB_OK);
}
else
{
MessageBox(hDlg, "No dot fuond.", "Search", MB_OK);
}