473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to copy from a vector into an array?

how to do it by using the copy algorithm of stl, please?

Apr 18 '06 #1
2 9397
co*******@gmail.com wrote:
how to do it by using the copy algorithm of stl, please?


Pointers into an array can be used as random access iterators.
Best

Kai-Uwe Bux
Apr 18 '06 #2
co*******@gmail.com wrote:
how to do it by using the copy algorithm of stl, please?


If v is your vector, and a is an array of sufficient length:

std::copy(v.begin(), v.end(), a) ;

Alan
Apr 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ishira | last post by:
Hello, Please help. I am seriously at my wits end. Just when I feel I have completely understood copy contructor, I am stumped yet again. I have a class which has a CARRAY of objects. I am...
30
by: franky.backeljauw | last post by:
Hello, I am wondering which of these two methods is the fastest: std::copy, which is included in the standard library, or a manually written pointer copy? Do any of you have any experience with...
1
by: Matt Garman | last post by:
What is the "best" way to copy a vector of strings to an array of character strings? By "best", I mean most elegantly/tersely written, but without any sacrifice in performance. I'm writing an...
4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
14
by: Jinjun Xu | last post by:
Hi, I have an array and I want to adjust the size (remove some elements). I use the following code. Can you help me to check whether it's correct. ////////////// start int *p1 = new int; ...
2
by: John | last post by:
I have a priority_queue that stores its elements in a vector. What is the fastest way to copy all the elements of the priority queue to this vector. Right now I use pop() to pop all the elements...
2
by: pragtideep | last post by:
Kindly help me explain the behaviour of defult copy constructor . Why the destructor is freeing the SAME memory twice , though it was allocated just once . #include<iostream> using namespace...
15
by: Frederick Gotham | last post by:
What's the canonical way to copy an array in C++? If we're copying a POD, we can use memcpy (but there could be a more efficient alternative if we know that the blocks are suitably aligned). ...
3
by: none | last post by:
Hi, Consider the following piece of code: int t={1,2,3,4,5,6}; vector<intv; std::copy (t, t+sizeof(t)/sizeof(t), std::back_inserter (v)); Could someone explain me why we can pass "t" as an...
5
by: zr | last post by:
Hi, Is there a way to initialize a std::tr1::array with a pre-allocated built-in array in a copy-less assignment, such that both will point to the same memory? Vice-versa is easy to do, simply...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.