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

# Simple pointer question (:)

 P: n/a Hi, I have an array: double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's values into 'array2'? TIA, -- JA Jul 22 '05 #1
5 Replies

 P: n/a "J" wrote in message news:Xn**********************@130.215.36.210... Hi, I have an array: double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's values into 'array2'? TIA, -- JA memcpy(array2, array, 50 * sizeof(double)); Jul 22 '05 #2

 P: n/a Thanks my friend, totally forgot memcpy. (Haven't programmed in awhile!!) - JA "Thomas Wintschel" wrote in news:PHTyb.91295 \$oN2.40286@edtnps84: "J" wrote in message news:Xn**********************@130.215.36.210... Hi, I have an array: double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's values into 'array2'? TIA, -- JA memcpy(array2, array, 50 * sizeof(double)); Jul 22 '05 #3

 P: n/a "J" wrote in message news:Xn**********************@130.215.36.210... Hi, I have an array: double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's values into 'array2'? std::copy(array, array + 50, array2); This assumes that 'array' and 'array2' each have at least 50 elements, and that all elements of 'array' have valid values. 'std::copy()' is declared by . -Mike Jul 22 '05 #4

 P: n/a Thomas Wintschel wrote: "J" wrote in message news:Xn**********************@130.215.36.210...Hi,I have an array:double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's valuesinto 'array2'? memcpy(array2, array, 50 * sizeof(double)); Hmm...whats memcpy doing in a c++ forum :-) Jul 22 '05 #5

 P: n/a "Roy Varghese" wrote in message news:RoYyb.391727\$Tr4.1147654@attbi_s03... Thomas Wintschel wrote: "J" wrote in message news:Xn**********************@130.215.36.210...Hi,I have an array:double *array = new double[50]; Well, I have 2 actually. double *array2 = new double[50]; Say 'array' is poulated with 'doubles'. How do I copy all of array's valuesinto 'array2'? memcpy(array2, array, 50 * sizeof(double)); Hmm...whats memcpy doing in a c++ forum :-) memcpy() is a standard C++ library function. -Mike Jul 22 '05 #6

### This discussion thread is closed

Replies have been disabled for this discussion.