fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. double* a;
  6. a = (double*)malloc(sizeof(double)*5);
  7. // ここまでで、double型の配列(長さ5)ができた。
  8. int i;
  9. for(i=0; i<5; i++) {
  10. a[i]=(double)i/10.0;
  11. printf("a[%d]のアドレスは %p\n",i,&(a[i]));
  12. printf("その中身は %lf\n",a[i]);
  13. }
  14.  
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
a[0]のアドレスは 0x560b666dd260
その中身は 0.000000
a[1]のアドレスは 0x560b666dd268
その中身は 0.100000
a[2]のアドレスは 0x560b666dd270
その中身は 0.200000
a[3]のアドレスは 0x560b666dd278
その中身は 0.300000
a[4]のアドレスは 0x560b666dd280
その中身は 0.400000