#include<iostream>
#include<string>
using namespace std;
void UpperCase(char str[])
{
int test1=sizeof(str);//这里的str表示指针
int test2=sizeof(str[0]);
cout<<"sizeof(str) is "<<test1<<" ."<<endl;
cout<<"sizeof(str[0]) is "<<test2<<"."<<endl;
for(size_t i=0;i<strlen(str);++i)
{
if('a'<=str[i]&&str[i]<='z')
str[i]-=('a'-'A');
}
}
int main()
{
char str[]="aBcDefG";
cout<<"the room of str is "<<sizeof(str)<<"."<<endl;
cout<<"The length of string is "<<strlen(str)<<"."<<endl;
UpperCase(str);
cout<<"The all uppercase string is "<<str<<endl;
return 0;
}
sizeof的使用
最新推荐文章于 2023-02-18 11:37:13 发布