how to implement strlwr in C source code

This snippet submitted by Syed Rafey Husain on 2005-11-22. It has been viewed 18331 times.
Rating of 5.3 with 94 votes

char * strlwr(char * s)
{
        char *t = s;

        if (!s)
        {
                return 0;
        }

        int i = 0;
        while ( *t != '\0' )
        {
                if (*t >= 'A' && *t <= 'Z' )
                {
                        *t = *t + ('a' - 'A');
                }
                t++;
        }

        return s;
}




More C and C++ source code snippets