Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

Assignment of structures

Structure assignment copies values of all members
[...]

struct point {
  int x;
  int y;
};
struct point a = {1, 2};
struct point b = a;

printf("x = %d, y = %d", b.x, b.y);
// Output: x = 1, y = 2

.

struct point {
  int xy[2];
};
struct point a= {{1, 2}};
struct point b= a;

printf("xy[0] = %d, xy[1] = %d", b.xy[0], b.xy[1]);
// Output: xy[0] = 1, xy[1] = 2
Answer
shallow copy only

Question

Assignment of structures

Structure assignment copies values of all members
[...]

struct point {
  int x;
  int y;
};
struct point a = {1, 2};
struct point b = a;

printf("x = %d, y = %d", b.x, b.y);
// Output: x = 1, y = 2

.

struct point {
  int xy[2];
};
struct point a= {{1, 2}};
struct point b= a;

printf("xy[0] = %d, xy[1] = %d", b.xy[0], b.xy[1]);
// Output: xy[0] = 1, xy[1] = 2
Answer
?

Question

Assignment of structures

Structure assignment copies values of all members
[...]

struct point {
  int x;
  int y;
};
struct point a = {1, 2};
struct point b = a;

printf("x = %d, y = %d", b.x, b.y);
// Output: x = 1, y = 2

.

struct point {
  int xy[2];
};
struct point a= {{1, 2}};
struct point b= a;

printf("xy[0] = %d, xy[1] = %d", b.xy[0], b.xy[1]);
// Output: xy[0] = 1, xy[1] = 2
Answer
shallow copy only
If you want to change selection, open original toplevel document below and click on "Move attachment"

Parent (intermediate) annotation

Open it
Assignment of structures Structure assignment copies values of all members ➜ shallow copy only struct point { int x; int y; }; struct point a = {1, 2}; struct point b = a; printf("x = %d, y = %d", b.x, b.y); // Output: x = 1, y = 2 . struct point { int xy[2]; }; struct point a= {

Original toplevel document (pdf)

owner: pavestonelaboringuntitled - (no access) - 02 C Programming.pdf, p60

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.