declaring 2-d array dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shoonya
    New Member
    • May 2007
    • 160

    declaring 2-d array dynamically

    Code:
    void foo(char *str){
    ...
    int arr[strlen(set)][strlen(set)];
    ..
    }
    certainly we can't do this in C.
    So how to implement this thing in C.
    Need help urgently
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Use malloc(). That will allocate the array on the heap.

    Be sure to free() the array when you are finished.

    Comment

    Working...