Hey JCL,

Before I typed the above code, I googled "Array manipulation C programming" and found many examples of both passing by pointer (function intArraySort(int *MyArray, blah, blah), and passing the the whole array (intArraySort(int &MyArray[], blah, blah) on forums and in C tutorials.

The function intArraySort(int *MyArray, int MyArraySize, string Method) doesn't work:( When I print the contents of each element in the array, I get random numbers:(

I have 2 problems with arrays in lite-c that cannot be resolved...

1. When passing an array by pointer, I need to know the memory size of a single element, then multiply that by the number of elements, so that I can tell the function the full size of the array, but we can only get the size of the pointer, so that won't work.

2. Any changes made to an array within a function has to be seen globally, so the array has to be both global in scope, and dynamic, which doesn't appear to be possible in lite-c frown

I have attached an mql4 script that I wrote to help me understand how to use & manipulate arrays in mql4... The functions ArraySort, ArrayRange, ArrayResize, FileReadArray, & FileWriteArray are built-in to mql4.

The functions StoreTrades, ClearClosedTrades, and TrimDoubleArrays in the script will show you what I wanted to do in lite-c.

So, it looks like I'll be using linked lists wink

I've had memory fragmentation errors when experimenting with a combination of pattern recognition & lowpass filter, so I guess the best way to avoid that when removing nodes from an LL is to allocate enough contiguous memory to contain the resized LL, then copy the nodes that I want to keep into a new LL in that space before freeing the original LL's memory. I'll have to figure out how to get the size of a single node first, though wink

Attached Files

Have fun!
Radar =8^)