We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.69 B 的答案是
typedef struct { long idx, long x[4] } a_struct
但是,实际上,根据对齐原则,idx 也可以是 int,short 和 char 类型。你可以修改以下 C 程序中设置,观察输出的结果。
#include <stdio.h> #define CNT 7 typedef struct { // 无论 idx 的类型为 char、short、int 或 long // 最后的 sizeof(b) 都是 0x128 // char idx; // short idx; // int idx; long idx; long x[4]; } a_struct; typedef struct { int first; a_struct a[CNT]; int last; } b_struct; int main(int argc, char const *argv[]) { a_struct a; b_struct b; printf("sizeof(a.idx) = %ld\n", sizeof(a.idx)); printf("sizeof(a) = %ld\n", sizeof(a)); printf("sizeof(b) = 0x%lX\n", sizeof(b)); return 0; }
The text was updated successfully, but these errors were encountered:
这是我的解答的地址 https://github.com/aQuaYi/CSAPP3E/blob/master/homework/03/3.69.md
Sorry, something went wrong.
有道理
No branches or pull requests
3.69 B 的答案是
但是,实际上,根据对齐原则,idx 也可以是 int,short 和 char 类型。你可以修改以下 C 程序中设置,观察输出的结果。
The text was updated successfully, but these errors were encountered: