Re: Dynamic Array Length ?
You would need to know the length or you could use the built in dynamic array, vector.
Re: Dynamic Array Length ?
Quote:
Originally Posted by
ron_a
How can i change or add a cell to an array without knowing its length ?
Have a look at CArray class and similar classes here
Re: Dynamic Array Length ?
You can change an element of an array by knowing its position in the array. As you are just changing the contents of the element, it doesn't change the size of the array. So providing you access a valid element (and c++ doesn't provide a check for this) you need to know its length to make sure the access is valid.
If you want to add a cell to an array, it depends upon how the array is implemented. To provide further help and guidance could you explain further what you mean by 'an array'. As you mentioned Dynamic Assigment, this seems like you are using dynamically allocated memory for the array? The STL vector is an array internally implemented via dynamically allocated memory. So using vector you can add elements to the end of the vector without knowing its size as the vector implementation deals with the dynamic memory requirements.
Can you clarify a bit more as what to are trying to do or want to know?
Re: Dynamic Array Length ?
Specifically, I think you are looking for CArray::SetAtGrow, which will dynamically enlarge the array.
http://msdn.microsoft.com/en-us/libr...v=vs.100).aspx
Re: Dynamic Array Length ?