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
28
|
<
div
class
=
"cnblogs_Highlighter"
><pre
class
=
"brush:cpp"
>#include <iostream>
using
namespace
std;
void
UpperCase(
char
str[] )
// 将 str 中的小写字母转换成大写字母
{
for
(
int
i=0; i<
sizeof
(str)/
sizeof
(str[0]); ++i )
if
(
'a'
<=str[i] && str[i]<=
'z'
)
str[i] -= (
'a'
-
'A'
);
}
int
main()
{
char
str[] =
"aBcDe"
;
cout<<
"str字符长度为: "
<<
sizeof
(str)/
sizeof
(str[0]) <<endl;
UpperCase( str );
cout<<str<< endl;
cout<<
"sizeof(“zhangdongsheng”)"
<<
sizeof
(
"zhangdongsheng"
)<<endl;
cout<<
"strlen(“zhangdongsheng”)"
<<
strlen
(
"zhangdongsheng"
)<<endl;
char
str2[]=
"zhangdongsheng"
;
UpperCase(str2);
cout<<str2<<endl;
return
0;
}
</pre>
</
div
>
|