Skip to content

Conversation

robertoraggi
Copy link
Owner

Enough for

int printf(const char* format, ...);

struct P {
  int x;
  int y;
};

int main() {
  struct P p;
  p.x = 10;
  p.y = 20;
  printf("%d + %d = %d\n", p.x, p.y, p.x + p.y);

  struct P* ptr = &p;
  printf("%d + %d = %d\n", ptr->x, ptr->y, ptr->x + ptr->y);

  ptr->x = 30;
  ptr->y = 40;
  printf("%d + %d = %d\n", ptr->x, ptr->y, ptr->x + ptr->y);
  printf("%d + %d = %d\n", p.x, p.y, p.x + p.y);

  return 0;
}
$ cxx -toolchain macos x.c -c

$ ld x.o -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk -lSystem

$ ./a.out 
10 + 20 = 30
10 + 20 = 30
30 + 40 = 70
30 + 40 = 70

@robertoraggi robertoraggi merged commit ba94f5d into main Aug 12, 2025
9 checks passed
@robertoraggi robertoraggi deleted the organisational-moose branch August 12, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant