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]);

		AssignCommand(TagArray[AutoInc],ActionRandomWalk());

		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.

TB12

Are you sure this is C? I ask because you have a type string.

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'*/
commented: Good list. Esp adding #4... +15

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.

It also supports the data type of string.

Then its not C. Why don't you write this in C++?

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

>>allows structs, but not objects.
string is an object, or more technically called c++ class.

Sorry. Dodgy tabs and computer reboot caused a double post.

You always can use list.
Your environment supports structures:

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


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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.