fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct
  5. {
  6. unsigned int nrows;
  7. unsigned int ncols;
  8. float* p;
  9. } matrix;
  10.  
  11. #define array(a,i,j) a.p[i*a.nrows+j] //???????????
  12.  
  13.  
  14. int main()
  15. {
  16. unsigned int i = 4, j = 5;
  17. float v = 154;
  18. matrix a;
  19.  
  20. a.nrows = i;
  21. a.ncols = j;
  22.  
  23. a.p = malloc(a.nrows * a.ncols * sizeof(float));
  24.  
  25. array(a, i-1, j-1)=v;
  26.  
  27. printf ("%f\n", array(a, i-1,j-1));
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
154.000000