【牛】请教兄弟姐妹们一个疑惑的问题,多谢
1、请看下面这个问题:
void UpperCase( char str[] ) // 将 str 中的小写字母转换成大写字母
{
for( size_t i=0; i< sizeof(str)/sizeof(str[0]); ++i )//为什么这儿sizeof(str)得到的是4呢?
if( 'a'<=str[i] && str[i]<='z' )
str[i] -= ('a'-'A' );
}
int _tmain(int argc, _TCHAR* argv[])
{
char str[] = "aBcDe";
cout << "str字符长度为: " << sizeof(str)/sizeof(str[0])<< endl;//这儿sizeof(str)得到的是6 UpperCase( str );
cout << str << endl;
cin.get();
return 0;
}