Start New Discussion within our Software Development Community

Hi there,
I am coding for an engine based on C that supports everything apart from arrays. Now what I want to do is this:

int Populate(int Amount, string TagArray[], float xLoc[], float yLoc[], float zLoc[], float Orient[])
	int AutoInc = 0;
	while(AutoInc < Amount)
              int a = AutoInc;              

		CreateObject(OBJECT_TYPE_CREATURE, TagArray[AutoInc], Location(Vector(xLoc[AutoInc], yLoc[AutoInc], zLoc[AutoInc]), Orient[AutoInc]);


       return 0;

I found out after writing this that the engine doesn't support arrays. Is there any way that I can do this without arrays?

I did have a look at structs but couldn't get my head around using them like this.

Thanks in advance.


I m used to using C++ so there is probably something wrong in there. Whats the C alternative?

C doesn't have objects. The closest thing is a C-string which is an array of characters terminated by '\0'.

char str1[] = "this is a string";/*compiler adds the '\0'*/
char *str2 = "this is another string";/* but its non mutable and the compiler adds the '\0'"*/
char str3[] = {'s','t','r','i','n','g','\0'};/*another string*/
char str4[]  = {'n','o','n'','-','s','t','r','i','n','g'};/*not a string no '\0'*/
Good list. Esp adding #4...

Unfortunately I can't use arrays. Is there any other way of doing what I want or should I just give it up?

You'll have to elaborate why the engine doesn't support arrays and what exactly it does support...We can't grab a crystal ball and gaze into your game engine.

Here is some info although it pretty much supports most things except arrays.

does not have many functions from the C family, excluding logical and binary / ternary operators and some mathematical functions

It also supports the data type of string.

allows structs, but not objects.

The following common data types are available

* integer (int)
* float
* string
* struct

Once again any help is appreciated.

Because I was told the engine is based on C. It is NWScript and has lots of its own variable types.

You always can use list.
Your environment supports structures:

typdef struct {
NODEtype *Next;
int Datatype;
unsigned long int DabaBlockSize;
void *DataBlock;

You an store any object in this node, and concatenate nodes to from a list.
by marking the first and last elements, you can traverse the list ack and forth using pointer arithmetics. Pass the list to any funciton by passing a pointer to any element of the list.Preferable, use the first element... but it is not a must.

This article has been dead for over six months. Start a new discussion instead.