fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct {
  4. int x;
  5. int y;
  6. int z;
  7. }coordinate;
  8.  
  9. int main(void) {
  10. coordinate me={0};
  11. coordinate *new_me=&me;
  12. //Coordinate:構造体の実体
  13. //(構造体の中身(メンバー変数)を直接保持している領域。今回でいう10行目の部分)
  14. //Coordinate*:構造体のアドレス(ポインタ)
  15. //(構造体の実体が存在するメモリ上の場所(アドレス)11行目のところ)
  16.  
  17. new_me ->x +=1;
  18. new_me ->y +=2;
  19. new_me ->z +=3;
  20.  
  21. printf("x:%d\n",me.x);
  22. printf("y:%d\n",me.y);
  23. printf("z:%d\n",me.z);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
x:1
y:2
z:3