UP | HOME

HW37
COP-3223H

Submit via webcourses.

Using only your mind and/or pencil and paper (do not compile and run the program) Write a program based on the in class example, but only change g and the call to g so that g will actually change the value of my_player to 6 and 6 and without using a return value. (Hint: use pointers to do this.)

#include <stdio.h>

struct player {
  int x;
  int y;

};


void g(struct player g_player) {
  g_player.x = 6;
  g_player.y = 6;
}

int main() {
  struct player my_player;

  my_player.x = 5;
  my_player.y = 5;

  g(my_player);

  printf("%d\n", my_player.x);
  printf("%d\n", my_player.y);
}

Author: Paul Gazzillo

Created: 2026-04-20 Mon 10:24

Validate