how to assign static array to a pointer array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jaikumar
    New Member
    • Sep 2006
    • 1

    #1

    how to assign static array to a pointer array

    hi ,
    i need the group members help

    I need to use pointer array to store list of static integers

    eg.

    uint16 *t_async = (uint16 *)malloc(35);

    * t_async[] = {29,30,39}; // this statement throws error.


    could anyone pls help.
    jai
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Originally posted by jaikumar
    uint16 *t_async = (uint16 *)malloc(35);
    You appear to have allocated memory for 17 /1/2 16 bit integers, is this may be a mistake?

    Originally posted by jaikumar
    * t_async[] = {29,30,39}; // this statement throws error.
    You can not assign an array to an array in C/C++ you can only initialise an array and you never have an array to initialise.

    You will have to

    Code:
      t_async[0] = 29;
      t_async[1] = 30;
      t_async[2] = 39;

    Comment

    Working...