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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:46:10+00:00 2026-06-16T13:46:10+00:00

I have some C code that I’m trying to convert/wrap into a C++ class.

  • 0

I have some C code that I’m trying to convert/wrap into a C++ class. I ran into some C literal arrays(correct me if I’m calling them wrong) and I’m not sure how to initialize them in the C++ constructor since I don’t think you can do literals, which I think are compile time specific, to something that is runtime specific.

Should I just explicitly define the array to be of a certain size and just do a strcpy, or some such, of the literal to the array in the constructor?

char sysUpTime[] = {1,3,6,1,2,1,1,3,0};
  • 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-16T13:46:11+00:00Added an answer on June 16, 2026 at 1:46 pm

    As an alternative to initializer lists or string manipulation, you could use something like the following (if you really wanted to):

    struct Wrapper
    {
        template <size_t N>
        Wrapper(const char(&arr)[N]) : vec(arr, arr+N) { }
    
        vector<char> vec;
    };
    

    I’ve left everything public due to chronic laziness on my part :). You can then initialise like this:

        char foo[] = { 1, 2, 3, 4, 5 };
        Wrapper bar(foo);
    
        copy(bar.vec.begin(), bar.vec.end(), ostream_iterator<int>(cout, ", "));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that inserts a record into a SQLite table: $statement =
I have some code that performs a deep copy using Object.clone, but I'm trying
I have some code that takes an externally provided class name, and needs to
I have some code that I'm trying to rewrite. The code is designed to
I have some code that I want to build. The code uses boost::ptr_map class
We have some code that we are trying to replace to deal with localization
I have some code that I wanted to put into a library which uses
I have some code that takes in a string, converts it into an Object
I have some code that i can insert into my Joomla 3.0 page that
I have some code that looks like this: <div class=container> <aside class=sidebar> <a href=index.php?Cat=members><h3>Members</h3></a>

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.