CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 1999
    Posts
    24

    How to copy one array to the end of another array?

    Urgent! Thank you very much.


  2. #2
    Join Date
    Sep 1999
    Posts
    15

    Re: How to copy one array to the end of another array?

    First you get the length of both Arrays: short int thing[] = {1,2,3,4};
    int length = sizeof thing / sizeof (short);
    And then if had both lengths add both to one: lenght += length2;
    And then create a new Array: int *array = new int [length];
    And then copy both arrays into the one and to not forget to delete the both arrays
    for (int i =0; i<=length; i++)
    { array[i]=thing[i];} and delete thing.


  3. #3
    Join Date
    May 1999
    Posts
    318

    Re: How to copy one array to the end of another array?

    The best method could be to use memcpy


    int i[10];
    int j[10];
    memcpy( &i[10], j, sizeof(int)*10 );






Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured