Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- /////////////////////////////////
- struct Big
- {
- int length;
- int width;
- int nMax;
- };
- void foo(Big *);
- ////////////////////////////////////////////
- int main()
- {
- Big b;
- b.length = 12;
- b. width = 2;
- b. nMax = 5;
- foo(&b);
- }
- /////////////////////////////////////////////
- void foo(Big *p)
- {
- printf(" - - - - - \n");
- printf("address b.length = %d\n", &p->length);
- printf("address b. width = %d\n", &p-> width);
- printf("address b. nMax = %d\n", &p-> nMax);
- printf(" p = %d\n", p);
- char *pn = (char*)p;
- pn = pn + 4;
- printf(" pn = %d\n", pn);
- // Распечатать адреса всех полей структуры без упоминания их имён
- }
- /*
- #include<stdio.h>
- /////////////////////////////////
- struct Big
- {
- int length;
- int width;
- };
- void foo(Big *);
- ////////////////////////////////////////////
- int main()
- {
- Big a, b;
- a.length = 12;
- b.length = 5;
- b. width = 2;
- printf(" a.length = %d\n", a.length);
- printf("address a.length = %d\n", & a.length);
- printf("address a. width = %d\n", & a. width);
- foo(&b);
- }
- /////////////////////////////////////////////
- void foo(Big *p)
- {
- printf(" - - - - - \n");
- printf("address b.length = %d\n", &p->length);
- printf("address b. width = %d\n", &p-> width);
- printf(" p = %d\n", p);
- char *pn = (char*)p;
- pn = pn + 4;
- printf(" pn = %d\n", pn);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement