fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct{
  4. int x;
  5. int y;
  6. } coordinate;
  7.  
  8. coordinate move_x(coordinate player);//coordinateはvoidと同じ感じ。意味は「座標」
  9.  
  10. int main(void)
  11. {
  12. coordinate me = {1, 2};
  13.  
  14. coordinate new_me = move_x(me);//move_x(me)で21行目の関数を呼び出してる
  15.  
  16. printf("me(%d,%d)\n",me.x,me.y);
  17. printf("new_me(%d, %d)\n", new_me.x, new_me.y);
  18. return 0;
  19. }
  20.  
  21. coordinate move_x(coordinate player)
  22. {
  23. player.x += 1;
  24. return player;
  25. }
  26.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
me(1,2)
new_me(2, 2)