View Single Post
Old 04-24-2002, 06:05 PM   #1
Sitral
New Member
 
Join Date: Apr 2002
Posts: 11
Sitral is on a distinguished road
Red face

Let me start by saying I'm as green as they get, so bear with me.  I'm also not familiar with this type of forum, so I hope this posts correctly...

This _seems_ simple enough, but I'm running into errors.  The long and short of it is this: I want to take what a character puts in and store it in a structure, along these lines:

[code]
struct form { char * input[MAX_STRING_LENGTH]; };
struct form structure { '\0' };
for( i=0; structire.input[i] != '\0'; i++ ) {}
/* If there's something there, skip it! */
structure.input[i] = argument;
/* After we found a blank spot, store the input. */
[/quote]

I want the user to be able to "store say haha!", "store say You're under my power!", "store say Foolish mortal!", then be able to execute all three says with one command. It stores the first one fine, but when I try to store a second command, it changes the first to what I want the second to be, and adds that second.  When I store a third command, all three become that last command.  The above example would store "say Foolish mortal!" three times.

First thing that came to my mind is that there had to be a problem with my for statement, but a bit of elementary debugging seems to prove it works fine.  I then recalled (and verified) that every instance of an array in my book (a poor one, I'm told) only has single characters.  Can 'structure.input[0] = say hahaha!'?  Can/Must I use a multi-dimentional array to store strings?  That last didn't seem to work for me...

Hope it was clear and concise. Thanks.
Sitral is offline   Reply With Quote