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 3614206
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:13:11+00:00 2026-05-18T22:13:11+00:00

I would appreciate for some C++ expertize advice on this please. I have a

  • 0

I would appreciate for some C++ expertize advice on this please. I have a Char array

     <unsigned char ch1[100];> 

data (ASCII code) gets filled in this ( max 6 or 8 array spaces and rest is empty). I want to process valid bits in the array only either converting them to Hex or again Char array. I tried

     <memcpy (ch1,ch2,sizeof(ch1))>

but all garbage values are also copied….. 🙁

       <strcpy gives me an error>

also number of bytes copied are dynamic ( 1 time :- 4; 2 time :- 6…..)

  • 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-05-18T22:13:11+00:00Added an answer on May 18, 2026 at 10:13 pm

    Do you know how many valid bytes do you have in your array? If yes, you can pass that number in as the 3rd argument of memcpy.

    Otherwise you can zero-initialize the array and use strcpy which will stop on the first zero:

    char ch1[100];
    // zero out the array so we'll know where to stop copying
    memset(ch1, 0, sizeof(ch1));
    
    ... data gets filled here ....
    
    strcpy (ch2, ch1);
    // zero out array again so we'll catch the next characters that come in
    memset(ch1, 0, sizeof(ch1));
    
    ... life goes on ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would appreciate some advice related to manipulating data in vectors. I have written
I have a problem finding references to this subject and would appreciate some help.
I'm having something of a dilemma and would appreciate some input. I have this
I would appreciate some help. I have used this before and it worked fine.
I am new android and I would appreciate some help. I have this code:
I have run out of ideas on this issue and would appreciate some help
I would appreciate some help on this. I have this table: RECHARGES ___________ DATE_TIME
This is really frustrating I would appreciate some help with this. I have a
I would appreciate some help with something I working on and have not done
I would appreciate some help with the following issue - you can see this

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.