Results 1 to 2 of 2

Thread: Assign 2D Arrays at runtime

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    East Ballina,NSW,Australia
    Posts
    121

    Exclamation Assign 2D Arrays at runtime

    Hi All,

    Just a quick question with hopefully, a quikc and easy answer.
    I want to assign a few arrays to a char at runtime after the 2d arrary has been declared...
    So basically I want to do this......
    char mychar [10] [10] ={ {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , 'W' , '~' , '~'},
    {'~' , 'T' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , 'Y' , '~' , '~' , '~'},
    {'~' , 'B' , '~' , 'B' , '~' , 'G' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'} };

    but instead of assigning it at the start I want to assign it at runtime.

    i have tried doing something like this....
    mychar [10] [10] ={ {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , 'W' , '~' , '~'},
    {'~' , 'T' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , 'Y' , '~' , '~' , '~'},
    {'~' , 'B' , '~' , 'B' , '~' , 'G' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'},
    {'~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~' , '~'} };

    but the compiler is giving me errors.

    Any Help would be greatly appreciated.

    Thanks!

    Best Regards,

    Smithy.

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    If you know at runtime what you might want to assign to it, then you can make another array the same size and everything, and when you want to assign it just use memcpy() to copy the memory from the resource array to this mychar array.
    Harry.

    "From one thing, know ten thousand things."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width