两个sizeof用法

简介:
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 >
目录
打赏
0
0
0
0
265
分享
相关文章
snprintf的用法
简要介绍了snprintf的常用方法,能大大的简化我们的代码
详解sizeof()和strlen()的细节及用法
详解sizeof()和strlen()的细节及用法
62 1
详解sizeof()和strlen()的细节及用法
|
9月前
|
struct 和 typedef struct 区别和用法总结
struct 和 typedef struct 区别和用法总结
174 0
C/C中sizeof和strlen函数的实现:详细解析sizeof和strlen函数的实现机制、参数说明和使用技巧
C/C中sizeof和strlen函数的实现:详细解析sizeof和strlen函数的实现机制、参数说明和使用技巧
112 1
|
9月前
|
typedef 和 # define 用法区别
typedef 和 # define 用法区别
80 0
|
9月前
strlen与sizeof 的基本用法
strlen与sizeof 的基本用法
70 0
|
9月前
|
C++
浅学指针(5)sizeof和strlen的进阶理解
浅学指针(5)sizeof和strlen的进阶理解
指针进阶(3) -- 关于sizeof和strlen的详细总结(上)
指针进阶(3) -- 关于sizeof和strlen的详细总结(上)
指针进阶(3) -- 关于sizeof和strlen的详细总结(下)
指针进阶(3) -- 关于sizeof和strlen的详细总结(下)
指针进阶(3) -- 关于sizeof和strlen的详细总结(中)
指针进阶(3) -- 关于sizeof和strlen的详细总结(中)

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等