fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. int* a;
  6. a = (int*)malloc(sizeof(int) * 4);
  7.  
  8. for(int i=0;i<4;i++){
  9. printf("a[%d]=%d\n",i,i);
  10. }
  11.  
  12. for(int i = 0; i < 4; i++){
  13. printf("a[%d] のアドレスは %p\n", i, &a[i]);
  14. printf("その中身は %d\n", a[i]);
  15. }
  16.  
  17. free(a);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
a[0]=0
a[1]=1
a[2]=2
a[3]=3
a[0] のアドレスは 0x56312817e260
その中身は 0
a[1] のアドレスは 0x56312817e264
その中身は 0
a[2] のアドレスは 0x56312817e268
その中身は 0
a[3] のアドレスは 0x56312817e26c
その中身は 0