質問編集履歴
1
コードを追記しました。宜しくお願いします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,81 @@
|
|
1
1
|
toupper()やtolower()の返り値や引数はint型であるのに、なぜ文字コードの数値でなく、文字が返ってくるのかが分からないので、その理由が知りたいです。
|
2
2
|
|
3
3
|
宜しくお願いします。
|
4
|
+
|
5
|
+
```
|
6
|
+
|
7
|
+
#define _CRT_SECURE_NO_WARNINGS
|
8
|
+
|
9
|
+
#include <stdio.h>
|
10
|
+
|
11
|
+
#include <ctype.h>
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
void str_toupper(char s[])
|
16
|
+
|
17
|
+
{
|
18
|
+
|
19
|
+
int i = 0;
|
20
|
+
|
21
|
+
while (s[i]) {
|
22
|
+
|
23
|
+
s[i] = toupper(s[i]);
|
24
|
+
|
25
|
+
i++;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
void str_tolower(char s[])
|
34
|
+
|
35
|
+
{
|
36
|
+
|
37
|
+
int i = 0;
|
38
|
+
|
39
|
+
while (s[i]) {
|
40
|
+
|
41
|
+
s[i] = tolower(s[i]);
|
42
|
+
|
43
|
+
i++;
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
int main(void)
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
char str[128];
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
printf("文字列を入力してください:");
|
60
|
+
|
61
|
+
scanf("%s", str);
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
str_toupper(str);
|
66
|
+
|
67
|
+
printf("大文字:%s\n", str);
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
str_tolower(str);
|
72
|
+
|
73
|
+
printf("小文字:%s", str);
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
return 0;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
```
|