// clean the blanks of a string
bool TrimBlank(char *source)
{
int len = strlen(source);
bool TrimBlank(char *source)
{
int len = strlen(source);
// blanks in the back
while (' ' == source[--len] && len >= 0);
while (' ' == source[--len] && len >= 0);
if(len < 0)
{
// all are blanks
return false;
}
{
// all are blanks
return false;
}
source[len+1] = 0;
// blanks in the front
// count blanks front
int cbf = 0;
while (' ' == source[cbf++]);
cbf--;
// count blanks front
int cbf = 0;
while (' ' == source[cbf++]);
cbf--;
len = strlen(source);
for (int i = 0; i < len - cbf; i++)
{
source[i] = source[i+cbf];
}
source[i] = 0;
{
source[i] = source[i+cbf];
}
source[i] = 0;
return true;
}
}