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

  • Home
  • SEARCH
  • 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 9142227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:44:59+00:00 2026-06-17T09:44:59+00:00

I hope I’ve titled my question correctly. I have a very large/old database with

  • 0

I hope I’ve titled my question correctly.

I have a very large/old database with many non-null terminated char arrays and a few std::string types. I’m creating a tool that will use this database, and I’d like to ensure it’s safety with respect to the non-null terminated char arrays. Ideally I’d like to support both types to make it easy for the developer to use the tool.

void AddCell( const std::string & _cell_str );
void AddCell( const char * _cell_data, size_t _array_size );

However, there’s a specific scenario that could be problematic: if a new developer is unaware that the char array is non-null terminated and out of laziness decides to use the implicit conversion of the std::string because he doesn’t have to enter the array size, then it’s possible that the std::string will show some unwanted chars.

How can I deal with this problem? Should I force someone to specify the length of the std::string? Should I just remove the std::string overloaded function and make everyone use c_str() from their std::string? Ideally, I’d just use the explicit keyword, but it’s only available for constructors. I’m hesitant to steer away from the use of std::string.

  • 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-17T09:44:59+00:00Added an answer on June 17, 2026 at 9:44 am

    You can change the first overload so that instead of taking a std::string reference it takes a reference to a new type that you create that has an implicit conversion from std::string. So you won’t see the implicit conversion from const char*, but will take std::string with no problems.

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

Sidebar

Related Questions

Hope I'm asking this correctly: I have a project Projects.Client I have my class
Hope you are fine. My question : In MYSQL i have a table with
hope all of you doing well. I have small question in C#.Net. actually i
hope you can help me! I have a form, which has a large amount
hope someone can help a noob. Many thanks in advance. I have an index
Hope you all are fine and rocking your code editors. My question is how
Hope this question is not stupid since I am an amateur web designer. I
Hope the AWK gurus can provide a solution to my problem . I have
Hope someone could help me with this: I would like to have a column
Hope someone will give me a hand with this problem I have. So here

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.