Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:10:33+00:00 2026-06-08T02:10:33+00:00

I have two arrays in C++ and I’d like to append one to the

  • 0

I have two arrays in C++ and I’d like to append one to the end of the other such that:

char byte1[] = {0x00};
char byte2[] = {0x01};

Appending these two should yield {0x00, 0x01}. How would I do this? It’s simple enough in Java using System.arraycopy(), but I’m not sure what library would help me to accomplish this in C++ / C as I’m coding for a microcontroller.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:10:34+00:00Added an answer on June 8, 2026 at 2:10 am

    If you’re using C, you can do:

    //Whatever sizes your stating arrays are.
    const int S_ARR1 = 3;
    const int S_ARR2 = 2;
    
    //Create buffer that can hold both.
    char combined[S_ARR1 + S_arr2];
    
    //Copy arrays in individually.
    memcpy(combined, byte1, S_ARR1);
    memcpy(combined + S_ARR1, byte2, S_ARR2);
    

    If you want C++, don’t use the byte arrays in the first place. Use std::vector as it acts as an array that can track its own number of elements so you can feel more like you’re in the java world 🙂

    A little warning though about C++ Vector Memory for Embedded:

    You’re in a micro-controller, std::vector can waste alot of memory as it grows based on a multiple of current size. The more that’s in it, the more you could be wasting. Having said that, it’s a great class and as long as you know how it handles its memory its a great option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays. I'd like to copy ranges of data from one of
I have two arrays, one is very large (more than million entries) and other
I have two arrays, one called words, the other called data. I have trouble
I have two arrays of values that I would like to combine - but
I have two arrays of strings that I would like to compare for equality:
I have two arrays, one is for a case and other one for b
I have two arrays. One is an array of names and the other is
I have two arrays, one that is made up of NSDates and one that's
I have two arrays. One for input boxes and other for checkbox. inputbox[] checkbox[]
I have two arrays in php that contain custom class objects. One I iterate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.