- Joined
- Jan 13, 2008
- Messages
- 2,302
- Reaction score
- 6
- Points
- 38
- Location
- Atlanta, GA, USA, North America
In my latest project I've come across the need to store a dynamically allocated array of char pointers such that chararray[0] = "some string", chararray[1] = "some other string" etc. A double pointer seems appropriate here, but I'm having some problems making it work.
In the .h file, I have:
Then in the .cpp file, In clbkLoadState, I'm using this first to dynamically allocate the array, then to store stuff to it:
For some reason, it always executes the second "else if" statement twice, but never more than twice before crashing. The scenario file it's reading from is correct in its syntax. The size variable is also correct (checked by writing to Orbiter.log). And yes, I AM deleting paylist in the destructor.
Thanks for any help,
Zat
In the .h file, I have:
Code:
char **paylist; //declare the double pointer
Code:
else if(!_strnicmp(line, "PAYNUMBER", 9))
{
sscanf(line+9, "%d", &size);
paylist = new char *[size]; //dynamically allocate the array
}
else if(!_strnicmp(line, "PAYLOAD", 7))
{
if(index < size)
{
sscanf(line+7, "%s", paylist[index]
index++ //increments the index variable to allow for multiple PAYLOAD definitions
}
}
Thanks for any help,
Zat