|
예전에 만들어 둔건데..
근데.. 이런 함수 필요하신거 맞나요? -_-;;
//------------------------------------------------------------------------------
bool IsDigit(AnsiString &str)
{
int i;
char *p = str.c_str();
char *s;
int len = strlen(p);
if(len == 0)
return false;
bool charstart = false;
bool charend = false;
bool cipher = false;
bool numericstart = false;
for(i=0;i<len;i++)
{
s = p + i;
if( *s == ' ' || *s == '\t')
{
if(charstart == false)
{
continue;
}
else
{
charend = true;
continue;
}
}
charstart = true;
if(charend == true)
return false;
if( *s == '-' || *s == '+' )
{
if(cipher == false)
{
cipher = true;
continue;
}
else
return false;
}
if( !(*s >= '0' && *s <= '9') )
{
return false;
}
else
numericstart = true;
}
return numericstart;
}
//------------------------------------------------------------------------------
bool IsFloat(AnsiString &str)
{
int i;
char *p = str.c_str();
char *s;
int len = strlen(p);
if(len == 0)
return false;
bool dot = false;
bool charstart = false;
bool charend = false;
bool cipher = false;
bool numericstart = false;
for(i=0;i<len;i++)
{
s = p + i;
if( *s == ' ' || *s == '\t')
{
if(charstart == false)
{
continue;
}
else
{
charend = true;
continue;
}
}
charstart = true;
if(charend == true)
return false;
if( *s == '-' || *s == '+' )
{
if(cipher == false)
{
cipher = true;
continue;
}
else
return false;
}
if( *s == '.' )
{
if(dot == false)
{
dot = true;
continue;
}
else
return false;
}
if( !(*s >= '0' && *s <= '9') )
{
return false;
}
else
numericstart = true;
}
return numericstart;
}
|