Hi,
I am trying to write a C program to trim whitespaces before the string. But, it isn't working properly. Following is what I tried
char *lefttrim(char *str)
{
int i=0;
while(strlen(str) > 0 && str[0] == ' ')
{
for(i = 1; i< strlen(str); i++)
{
str[i-1] = str[i];
str[strlen(str)] = '\0';
}
return(str);
}
It would be great if someone can point out some mistake.
Thanks,
Pingoo