Just looking for a few eyes on this code other than my own.
void TrimCString(cha r *str)
{
// Trim whitespace from beginning:
size_t i = 0;
size_t j;
while(isspace(s tr[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(s tr[i]))
{
i--;
}
if(i < (strlen(str) - 1))
{
str[i + 1] = '\0';
}
}
void TrimCString(cha r *str)
{
// Trim whitespace from beginning:
size_t i = 0;
size_t j;
while(isspace(s tr[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(s tr[i]))
{
i--;
}
if(i < (strlen(str) - 1))
{
str[i + 1] = '\0';
}
}
Comment