Posted By: CanadianDavid
Script crash with array of engine objects after wait(1) - 06/24/14 21:31
Can anyone explain why the following simple program crashes after the TEXT* objects' first strings are printed for the first time?
The code works fine when it is outside the while loop; the code works until a wait(1) is encountered.
Code:
#include <acknex.h> #include <default.c> TEXT** makeTexts() { TEXT* array[2]; array[0] = txt_create(10, 1); array[1] = txt_create(10, 1); int i; for(i=0; i<10; i++){ str_cpy((array[0].pstring)[i], "Text1"); str_cpy((array[1].pstring)[i], "Text2"); } return array; } function printMessages(TEXT** array){ printf("%s", _chr((array[0].pstring)[0])); printf("%s", _chr((array[1].pstring)[0])); } function main() { TEXT** array = makeTexts(); while(1){ printMessages(array); wait(1); } }
The code works fine when it is outside the while loop; the code works until a wait(1) is encountered.