[Dev-C++] Structures and Arrays and Pointers, Oh My!
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: David M. <ci...@ya...> - 2003-05-09 02:52:05
|
Ok, I am having trouble using the above 3 together. Slay_msg is a array of pointers to characters (strings)struct pc_data { char * slay_msg[3];} //a pointer to pc_data is a member of the char_data struct.struct char_data { ... pc_data * pcdata;} //A pointer is declared of type char_data and initalized to the required values.char_data * ch = new char_data; //Assume everything has been initalized. My question is: How do I access the strings in the array slay_msg? ch->pcdata->slay_msg[<index here>];seemed logical to me. however I am getting Null pointer assertion errors and nothing is done.when a '&' is placed before the ch it causes a crash. I am about to try putting a '*' before thech though I seriously doubt this will work. N.B. As is this is a pure C program. I would like to leave it that way.
---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo. |