|
3 registered members (Grant, Quad, AndrewAMD),
5,599
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Problems with structs
#239385
12/04/08 12:49
12/04/08 12:49
|
Joined: Oct 2008
Posts: 10 Italy
Romeoxbm
OP
Newbie
|
OP
Newbie
Joined: Oct 2008
Posts: 10
Italy
|
Hi all!!! I've got a problem with two nested structs...declared in this way:
typedef struct
{
ENTITY* character;
STRING* sentence_content;
STRING* oggFile;
} *sentence;
typedef struct
{
STRING* dialogueName;
int sentenceCount;
sentence sentenceArray[100];
} *dialogue;
int dialoguesCount = 1;
dialogue dialoguesArray;
I've got a crash into this function:
function dialogues_init()
{
if (Character1 == NULL)
Character1 = ent_create("sf_alien.mdl", vector(-50,0,0), NULL );
if (Character2 == NULL)
Character2 = ent_create("marine.mdl", vector(50,100,0), NULL );
dialoguesArray = (dialogue*)malloc(dialoguesCount*sizeof(dialogue));
dialoguesArray[0].sentenceCount = 3;
dialoguesArray[0].dialogueName = str_create("testDialog");
dialoguesArray[0].sentenceArray[0].sentence_content = str_create("Jack - Hi!");
dialoguesArray[0].sentenceArray[0].oggFile = str_create("dialog00.ogg");
dialoguesArray[0].sentenceArray[0].character = Character1;
dialoguesArray[0].sentenceArray[1].sentence_content = str_create("John - Hi Jack!! What's up?");
dialoguesArray[0].sentenceArray[1].oggFile = str_create("dialog01.ogg");
dialoguesArray[0].sentenceArray[1].character = Character2;
dialoguesArray[0].sentenceArray[2].sentence_content = str_create("Jack - Fine");
dialoguesArray[0].sentenceArray[2].oggFile = str_create("dialog02.ogg");
dialoguesArray[0].sentenceArray[2].character = Character1;
}
precisely, i've got (Error E1513 crash in dialogues_init) in the following code line:
dialoguesArray[0].sentenceArray[1].sentence_content = str_create("John - Hi Jack!! What's up?");
|
|
|
Re: Problems with structs
[Re: Azrael85]
#239470
12/04/08 20:56
12/04/08 20:56
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Joey said that you don't have to write stars in front of the struct definition name, so it should be "typedef struct { ... } dialog;" and "typedef struct { ... } sentence;".
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|