On Fri, 5 Dec 1997, Chuck Reed wrote: ->char *abil_desc_parse = { ->"blah blah blah blah blah \r\n ->blah blah blah blah blah\r\n", -> ->"\0" ->}; Apparently not. Let's review: char abil_desc_parse[] = { "This is a single string!" }; If you do "abil_desc_parse[0]" to this, you get the *letter* 'T'. This is an array of characters (essentially what a string is). You currently have: char *abil_desc_parse = { ... }; which is invalid. That's a pointer to a string, which would be done with: char *abil_desc_parse = "This is also a single string!"; But, neither of these things is what you want. You want an array of strings, so that "abil_desc_parse[0]" gives you a string. So you want: char *abil_desc_parse[] = { "This is one string.", "This is another string.", "This is the last one." }; Stuff like this is done elsewhere in the CircleMUD code (top of class.c comes to mind). It's a pretty simple concept, and doesn't even involve having to understand pointers, really. Just realizing the difference between an array of characters and an array of strings. This, "char abil_desc_parse;" is a single character. This, "char abil_desc_parse[];" is an array of single characters (thus creating ONE, and ONLY one, string). This, "char *abil_desc_parse;" is a char pointer--to not go into too much detail on how pointers actually work, we'll just say that we can use it to point to a place in memory that contains a SINGLE string of characters (char *ptr = "ptr now points to this string in memory.\r\n";). To get an array of strings, we typically do, "char *abil_desc_parse[];" because this gives us multiple pointers to strings in memory. To use similie, which is often more confusing than not, "char ch;" is like a single lego. "char array[];" is like some legos put together to form, say, a wall. "char *ptr;" is a pointer, which essentially says, "Everytime someone looks here, I'll redirect them so they are looking at whatever I'm pointing to." And, "char *array_of_ptr[];" is like a whole collection of lego-shapes. That probably didn't clear up a damn thing...:) ->struct abil_desc *ab_desc[] = { I doubt you want to use a pointer here. Remove the '*'. daniel koepke / dkoepke@california.com +------------------------------------------------------------+ | 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