-
how do you use tolower()
hello, I have a character array with a string in it and it has an uppercase letter, I'm trying to convert it to all lowercase letters, I heard that the function tolower can be used, i put the ctype.h header in but i can't get it to turn my capital letter to a lower case letter
could anyone tell me what am I doing wrong, here is my code, it's pretty simple
thank you
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main() {
char word[] = "Hello";
int n = 0;
printf(" %s \n ", word);
while ( n <= 3 ){
tolower( word[n]);
n++; }
printf(" %s \n ", word);
getchar();}
-
tolower() can't store the modified character so you have to call it like:
Code:
word[n] = tolower( word[n] );
-
tolower() returns the converted letter. You have to write the returned value into your array word.
-
For tolower() you should include <ctype.h>.