This is not really a problem but I was curious as to what happened.
struct foo {
string desc;
};
foo bar [5];
Now whenever I refer to 'StrLen (bar[0].desc)', the game crashes with an obscure error message. However if, at some earlier point, I set 'bar[0].desc = ""; ', there is no problem.
It seems to work with regular strings though, is this an AGS bug?
strings in structs have to be declared as
char desc [256];
Strangely enough, my code works without any problems if I declare the string as a string. Whereas if I declare it as a character array, I cannot seem to initialize it with 'foo = "hello world" '.
It might work in some circumstances, but might crash in others.
That's because "string" is actually a pointer underneath. So you set your pointer to point at a constant string. This is not safe, especially if you try and chnage the string at a later point.
You shoudl use StrCopy(bar.desc, "hello world") instead.