質問編集履歴
1
コードを追記しました。宜しくお願いします。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,2 +1,41 @@
|
|
1
1
|
toupper()やtolower()の返り値や引数はint型であるのに、なぜ文字コードの数値でなく、文字が返ってくるのかが分からないので、その理由が知りたいです。
|
2
|
-
宜しくお願いします。
|
2
|
+
宜しくお願いします。
|
3
|
+
```
|
4
|
+
#define _CRT_SECURE_NO_WARNINGS
|
5
|
+
#include <stdio.h>
|
6
|
+
#include <ctype.h>
|
7
|
+
|
8
|
+
void str_toupper(char s[])
|
9
|
+
{
|
10
|
+
int i = 0;
|
11
|
+
while (s[i]) {
|
12
|
+
s[i] = toupper(s[i]);
|
13
|
+
i++;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
void str_tolower(char s[])
|
18
|
+
{
|
19
|
+
int i = 0;
|
20
|
+
while (s[i]) {
|
21
|
+
s[i] = tolower(s[i]);
|
22
|
+
i++;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
int main(void)
|
27
|
+
{
|
28
|
+
char str[128];
|
29
|
+
|
30
|
+
printf("文字列を入力してください:");
|
31
|
+
scanf("%s", str);
|
32
|
+
|
33
|
+
str_toupper(str);
|
34
|
+
printf("大文字:%s\n", str);
|
35
|
+
|
36
|
+
str_tolower(str);
|
37
|
+
printf("小文字:%s", str);
|
38
|
+
|
39
|
+
return 0;
|
40
|
+
}
|
41
|
+
```
|