Re: CArray elements access
I dont know Why CArray size is growing. But to get the correct data, try this definition
CArray <FILEINFO, FILEINFO&> ... to get reference pointer for struct data
Re: CArray elements access
When you add your structure to the Array, your structure object is going out of scope.
This is how you should declare your CArray:
CArray<FILEINFO, &FILEINFO> m_ptArray;
This allows you to store pointers.
then do this to make a FILEINFO:
FILEINFO * fi = new FILEINFO;
m_ptArray.Add(fi);
By making a new structure, you are creating the data on the heap which is local to the whole program, versus creating data on the function's stack. As soon as the function that does this:
FILEINFO fi;
m_ptArray.Add(fi);
is over, fi is not valid anymore. That is why you have to use the new operator to create it on the heap.
Remember, when you use the GetAt operator, you have to cast the pointer you get back. a Simpler way is to used the CTypedPtrArray. The declaration would be like this:
CTypedPtrArray<CPtrArray, FILEINFO*> m_ptArray;
Then you don't have to cast everything.
Make sure you look in MSDN for proper ways to clean up CArrays...
Hope this helps...
kevin