某32位系统下, C++程序,请计算sizeof 的值

链接:https://www.nowcoder.com/questionTerminal/e29b5b80c95548218219359da07c12c3?orderByHotValue=0&done=0&pos=366&mutiTagIds=138&onlyReference=false
来源:牛客网
 

char str[] = "http://www.xxxxx.com" ;
char *p = str ;
int n = 10;
请计算
sizeof (str ) = 
sizeof ( p ) = 
sizeof ( n ) = 

void Foo ( char str[100]){

请计算 sizeof( str ) = 

}
void *p = malloc( 100 ); 请计算 sizeof ( p ) = 

正确答案:

1 21

2 4

3 4

扫描二维码关注公众号,回复: 10443364 查看本文章

4 4

5 4

解释:数组作为形参时,数组的数组名会退化成一个指向该类型数组的指针,只要是指针,在32位系统中所占的字节数就是4,在64位系统中所占的字节数是8.

发布了58 篇原创文章 · 获赞 7 · 访问量 3718

猜你喜欢

转载自blog.csdn.net/xy_learning/article/details/104654459
今日推荐