tolower() Convert a letter to lowercase
tolower() Convert a letter to lowercase
tolower() maps uppercase to lowercase in the current locale, leaving others unchanged. Pass EOF or unsigned char; it cannot decode UTF-8.
| Category | ctype.h character classes |
|---|---|
| Kind | Library function |
| Header | <ctype.h> |
| C standard | C89 / C90 |
📝 Syntax
int tolower(int c);
⚙️ Parameters
| c Required | The character to convert, represented as an unsigned char value or EOF. |
|---|
Returns: Returns the lowercase equivalent when one exists, or c unchanged otherwise.
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
hello 123
⚠️ Warning Passing a negative plain char value causes undefined behavior. Convert to unsigned char first; EOF may be passed directly.
💡 Tip tolower() returns the converted character value and does not modify an object in place.
🏷️ Related ctype.h functions
📚 Related Tutorials
❓ FAQ
QHow do I convert an entire string with tolower?
AIterate through a writable character array, pass each element as unsigned char to tolower, and assign the result back to that element.
QDoes tolower behave identically in every locale?
ANot necessarily; case mappings depend on the current locale. The default C locale guarantees basic A-Z to a-z conversion, while other language rules can differ.
QCan tolower convert a UTF-8 string byte by byte?
AIt cannot serve as a general Unicode lowercase conversion. Multibyte UTF-8 sequences must be decoded as a whole; byte-by-byte processing can encounter negative char arguments and cannot express case mappings that span bytes. Restrict the input range when handling only basic Latin letters, and use a dedicated library for full Unicode text.