EDITED的sizeof()嵌套結構陣列
#include<stdio.h>
typedef struct ns{
int sd;
int we;
char st;
int m;
}ds;
typedef struct numb
{
char b;
ds rt;
}num;
static num a[]={1,'a'};
int read(int number)
{
printf("%d\n",number);
return 1;
}
int main()
{
printf("%d",sizeof(a[0].rt));
read(sizeof(a[0].rt));
read(sizeof(a[0]));
return 0;
}
我的疑問是傳遞的sizeof當作爲參數將被修改爲臨時指針變量的陣列組成。但是,在嘗試打印sizeof時,它在結構數組以及嵌套結構數組中給出了實際大小。爲什麼包含結構數組的第二次讀取沒有被轉換爲指針作爲其數組。
你是什麼意思*輸出大小到大*? –
不,尺寸是正確的。你只需要調整你的期望。 –
您希望打印的尺寸是多少?你得到什麼結果?你的平臺是什麼? – mizo