Jump to content
  • Advertisement
Sign in to follow this  
Muncher

the fastest/best way to do this....

This topic is 4998 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, what is the fastest way to add an array of integers, to a current array of integers? (in C++) just for clarity... int arr1[500]; // temp array int arr2[1000]; // array i want to append values to // fill arr1 with values // fill arr2 with 500 values so // one way is to append arr2 with arr1 is...... for (int i = 0; i < 500; i++) arr2[500+i] = arr; But is there a faster way???? Cheers Paul

Share this post


Link to post
Share on other sites
Advertisement
I think you're looking for memcpy:


int arr1[500]; // temp array
int arr2[1000]; // array i want to append values to

for(int count=0; count<500; ++count) { // Fill arrays with values
arr2[count] = count;
arr1[count] = count+500;
}

memcpy(&arr2[500], arr1, 500*sizeof(int));


You might want to test that though [grin]

Share this post


Link to post
Share on other sites
Quote:
Original post by The Rug
I think you're looking for memcpy

Eh yeah, that's what I meant too ;)
You could use CopyMemory, but is Windows specific, I believe.


[Edited by - WanMaster on January 18, 2005 9:54:03 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!