Re: dynamic arrays ...problems creating them

Discussion in 'C Programming' started by Marco de Boer, Jul 3, 2003.

  1. Hi ram,
    "ram" <> wrote in message
    news:...
    > I have a link list having n nodes of type struct cq
    >
    > I want to create an array of pointers to each node and then pass this
    > array to the qsort function
    >
    > cq *l,*array;



    You want a pointer to an array of cq pointers : cq **array.

    >
    > array=(cq *)malloc(length*sizeof(cq));


    You only want to store nItem pointers:
    array=calloc(nItem,sizeof(cq*));

    >
    > i=0;
    > for (l=chd; l; l=l->next)
    > array[i++]=l; // I get an error here
    > incompatible types in assignment
    >
    > Why??
    >
    > Thanks for the help


    Don't forget to free the array !!!

    Marco
     
    Marco de Boer, Jul 3, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonieko

    HttpHandlers - Learn Them. Use Them.

    Anonieko, Jun 15, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    566
    tdavisjr
    Jun 16, 2006
  2. Tom St Denis

    Re: dynamic arrays ...problems creating them

    Tom St Denis, Jul 3, 2003, in forum: C Programming
    Replies:
    1
    Views:
    786
  3. monkeydragon

    Creating Dynamic 2D Arrays

    monkeydragon, Dec 15, 2005, in forum: C++
    Replies:
    2
    Views:
    346
    Axter
    Dec 15, 2005
  4. Philipp
    Replies:
    21
    Views:
    1,190
    Philipp
    Jan 20, 2009
  5. why the lucky stiff
    Replies:
    5
    Views:
    171
    why the lucky stiff
    Sep 22, 2004
Loading...

Share This Page