What is the method for converting the size of a charact…
You can use the standard library functions toupper() and tolower() in the C language ctype.h header file to convert the case of a character array.
The toupper() function converts a character to its uppercase form, and returns the original character if it is not a lowercase letter.
The tolower() function converts a character to lowercase. If the character is not an uppercase letter, the original character is returned.
Here is an example code using the toupper() and tolower() functions for case conversion:
#include <stdio.h>
#include <ctype.h>
void toUpperCase(char str[]) {
int i = 0;
while (str[i] != '\0') {
str[i] = toupper(str[i]);
i++;
}
}
void toLowerCase(char str[]) {
int i = 0;
while (str[i] != '\0') {
str[i] = tolower(str[i]);
i++;
}
}
int main() {
char str[] = "Hello World";
toUpperCase(str);
printf("Uppercase: %s\n", str);
toLowerCase(str);
printf("Lowercase: %s\n", str);
return 0;
}
Output result:
Uppercase: HELLO WORLD
Lowercase: hello world
In the example above, the toUpperCase() function converts all characters in a string to uppercase, while the toLowerCase() function converts all characters to lowercase.