435,197 Members | 1,207 Online
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

# concatenating vectors

 P: n/a I was just wondering if there is a built-in function for concatenating two STL vector objects. For instance, I might have a vector with 10 objects and one with 20. Then, I would call this built-in function to concatenate the vectors into a vector with 30 objects. Any help is appreciated. Thank you. Aug 10 '07 #1
5 Replies

 P: n/a mi******@gmail.com wrote: I was just wondering if there is a built-in function for concatenating two STL vector objects. For instance, I might have a vector with 10 objects and one with 20. Then, I would call this built-in function to concatenate the vectors into a vector with 30 objects. RTFM about the 'insert' member of 'std::vector'. You need the one with three iterator arguments. Basically you need to insert the second vector right before the end of the first one (hint, hint...) V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask Aug 10 '07 #2

 P: n/a ( cout, "\n" ) ); -- Bob R POVrookie Aug 10 '07 #3

 P: n/a mi******@gmail.com wrote: I was just wondering if there is a built-in function for concatenating two STL vector objects. For instance, I might have a vector with 10 objects and one with 20. Then, I would call this built-in function to concatenate the vectors into a vector with 30 objects. Any help is appreciated. Thank you. std::vector::append. Aug 10 '07 #4

 P: n/a Gianni Mariani wrote: mi******@gmail.com wrote: >I was just wondering if there is a built-in function forconcatenating two STL vector objects. For instance, I might have avector with 10 objects and one with 20. Then, I would call thisbuilt-in function to concatenate the vectors into a vector with 30objects. Any help is appreciated. Thank you. std::vector::append. Your library provides *that*? Wow! Are you sure you're not confusing 'std::vector' with 'std::string'? V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask Aug 10 '07 #5

 P: n/a Victor Bazarov wrote: Gianni Mariani wrote: >mi******@gmail.com wrote: >>I was just wondering if there is a built-in function forconcatenating two STL vector objects. For instance, I might have avector with 10 objects and one with 20. Then, I would call thisbuilt-in function to concatenate the vectors into a vector with 30objects. Any help is appreciated. Thank you. std::vector::append. Your library provides *that*? Wow! Are you sure you're not confusing 'std::vector' with 'std::string'? Oops - std::vector::insert ... Aug 10 '07 #6

### This discussion thread is closed

Replies have been disabled for this discussion.