blob: e63071875cdfa4a0a0adde7b08977179fc5a9944 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <stdio.h>
#define MAX_LEN 20
void lower_str(char source[], char dest[]);
char lower_char(char c);
int main() {
char s[] = "This Is A Test.";
char lowered[MAX_LEN];
lower_str(s, lowered);
printf("%s -> %s\n", s, lowered);
return 0;
}
void lower_str(char source[], char dest[]) {
int i;
for (i = 0; source[i]; i++)
dest[i] = lower_char(source[i]);
dest[i] = '\0';
}
char lower_char(char c) {
return c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c;
}
|