is that if there is anyway to copy those elements from list to an array
Yes, there is a way to copy objects from a container to another. You can use the following algorithm:
- get output iterator to the output container
- get input iterator to first element of the input container
- while input iterator does not point to the end
- dereference the iterator to get a reference to the element
- dereference the output iterator, and copy assign the element
- increment both iterators
You don’t need to write the loop yourself though because standard library already has done it for you: std::copy
.
0
solved How can i copy elements in list to an array c/c++