![](https://img2018.cnblogs.com/common/1315374/201912/1315374-20191220124005331-1042167459.png)
1 void StringCount(char* s)
2 {
3 int len = 0;
4 char* p = s;
5 int cap_letter = 0;
6 int sma_letter = 0;
7 int space = 0;
8 int digit = 0;
9 int other = 0;
10
11 while (*p != '\0')
12 {
13 len++;
14 p++;
15 }
16 for (int i = 0; i < len; i++)
17 {
18 if (s[i] >= 'A' && s[i] <= 'Z')
19 {
20 cap_letter++;
21 }
22 else if (s[i] >= 'a' && s[i] <= 'a')
23 {
24 sma_letter++;
25 }
26 else if (s[i] == ' ')
27 {
28 space++;
29 }
30 else if (s[i] >= '0' && s[i] <= '9')
31 {
32 digit++;
33 }
34 else
35 {
36 other++;
37 }
38 }
39
40 printf("%d %d %d %d %d\n", cap_letter, sma_letter, space, digit, other);
41
42 }