Re: memorize

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 10/02/97


On Fri, 3 Oct 1997, George wrote:

-+On Thu, 2 Oct 1997, Brian Williams - Nashak wrote:
-+
-+>Daniel, I'm not familiar with pointers besides char *.., how would I go
-+>about using a int *memorized; pointer? Would it be the same, just sprintf
-+>or something to add to it? How would I remove things from it and so forth
-+>when a spell is cast?
-+
-+It would be treated as an integer except for two things:
-+A) You have to allocate memory for it.  ie. malloc(sizeof(int))
-+B) You have to use the * operator to get the value.

Not exactly.  I mean, both are true, but only to a certain
extent.  The use I intended was:

  int *dynamic_array = NULL, array_size = 10;
  dynamic_array = (int *) realloc(dynamic_array, sizeof(int)*array_size);
  dynamic_array[0] = SPELL_MAGIC_MISSILE;

The thing I love about 'realloc' is that if dynamic_array==NULL, it
acts just like malloc().  Of course, you *can* do "*dynamic_array",
but it's not nearly as useful.


--
Daniel Koepke -:- dkoepke@california.com -:-  [Shadowlord/Nether]
Think.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST