|
-
May 18th, 2001, 12:13 AM
#1
Thread Starter
Lively Member
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.
-
May 18th, 2001, 04:43 AM
#2
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|