[code] memory question.

From: --Ben Horner-- (b-horner@WAITE.ADELAIDE.EDU.AU)
Date: 10/07/97


I am a new coder to c and have a memory allocation question,

Ok I set up a number of arrays containing selected phrases such as:
fantastic, good etc etc for my stats rolling system.

In the call that calls my function for rolling I added a array for these
to go into, thus:
I call my function and it returns a array of ONE of the selected phrases.

Now I understand that c allocates memory for a simple array of one
number, but can it allocate memory for this type of array? where it has a
selection of phrases to store?, do I need to malloc this and if so how?

The examples of malloc I have seen all refer to a linked structure, this
is definatly not a linked structure as in a section of code it is:

char *rolls_abils_result[5] = {"&0&1&bFantastic&0  ", "&0&2&bPretty
Good&0", "&0&3&bNot bad&0    ", "&0&3Fiar&0       ", "&0&9&bBad&0 ;

with the function returning a table of arrays, each pointing to one of these.


Anyway I hope someone understands what I mean and can help me out, any
info on when and why arrays need to have memory allocated would help.

2) Another small question the rollor in circlemud returns 6 values
(1-18), stored in table, why does table[0], table[1], value return higher
values? where is this setting?, I have notcied that this must be set on
purpose because for sorcerers there roll for int is table[0], but thieves
use dex as table[0], and warriors con table[0].

Anyway thanks for all the help,
Proky - Hubis


     +------------------------------------------------------------+
     | 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