dinamic allocator for structures

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuti
    New Member
    • Sep 2007
    • 1

    #1

    dinamic allocator for structures

    hi, i have to allocate dynamically the vectors in the structure:
    typedef struct
    {

    float *x;
    float *y;
    float *y2;

    int max_val;

    }
    boxtype;
    boxtype box[maxbox];

    i would that x,y e y2 must depens by x[n], y[n] e y2 [n] where n is an integer that is passed during program compiling.

    this is right way?:
    box[1].x = (float*) calloc (n,sizeof(float ));

    regards
  • ruskalym
    New Member
    • Sep 2007
    • 65

    #2
    This calls seems correct to me.

    Comment

    Working...