Comment on trim string function please
- From: "swengineer001@xxxxxxxxx" <swengineer001@xxxxxxxxx>
- Date: Thu, 10 Jul 2008 09:59:11 -0700 (PDT)
Just looking for a few eyes on this code other than my own.
void TrimCString(char *str)
{
// Trim whitespace from beginning:
size_t i = 0;
size_t j;
while(isspace(str[i]))
{
i++;
}
if(i > 0)
{
for(j = 0; i < strlen(str); j++, i++)
{
str[j] = str[i];
}
str[j] = '\0';
}
// Trim whitespace from end:
i = strlen(str) - 1;
while(isspace(str[i]))
{
i--;
}
if(i < (strlen(str) - 1))
{
str[i + 1] = '\0';
}
}
.
- Follow-Ups:
- Re: Comment on trim string function please
- From: lovecreatesbea...@xxxxxxxxx
- Re: Comment on trim string function please
- From: swengineer001@xxxxxxxxx
- Re: Comment on trim string function please
- From: swengineer001@xxxxxxxxx
- Re: Comment on trim string function please
- From: Eric Sosman
- Re: Comment on trim string function please
- From: badc0de4
- Re: Comment on trim string function please
- From: Jens Thoms Toerring
- Re: Comment on trim string function please
- Prev by Date: Re: need help
- Next by Date: Re: volatile and multiple threads
- Previous by thread: volatile and multiple threads
- Next by thread: Re: Comment on trim string function please
- Index(es):
Relevant Pages
|