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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:51:06+00:00 2026-05-12T07:51:06+00:00

I can see that almost all modern APIs are developed in the C language.

  • 0

I can see that almost all modern APIs are developed in the C language. There are reasons for that: processing speed, low level language, cross platform and so on.

Nowadays, I program in C++ because of its Object Orientation, the use of string, the STL but, mainly because it is a better C.

However when my C++ programs need to interact with C APIs I really get upset when I need to convert char[] types to C++ strings, then operate on these strings using its powerful methods, and finally convert from theses strings to char[] again (because the API needs to receive char[]).

If I repeat these operations for millions of records the processing times are higher because of the conversion task.
For that simple reason, I feel that char[] is an obstacle in the moment to assume the C++ as a better c.

I would like to know if you feel the same, if not (I hope so!) I really would like to know which is the best way for C++ to coexist with char[] types without doing those awful conversions.
Thanks for your attention.

  • 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-12T07:51:07+00:00Added an answer on May 12, 2026 at 7:51 am

    The C++ string class has a lot of problems, and yes, what you’re describing is one of them.

    More specifically, there is no way to do string processing without creating a copy of the string, which may be expensive.

    And because virtually all string processing algorithms are implemented as class members, they can only be used on the string class.

    A solution you might want to experiment with is the combination of Boost.Range and Boost.StringAlgo.

    Range allows you to create sequences out of a pair of iterators. They don’t take ownership of the data, so they don’t copy the string. they just point to the beginning and end of your char* string.

    And Boost.StringAlgo implements all the common string operations as non-member functions, that can be applied to any sequence of characters. Such as, for example, a Boost range.

    The combination of these two libraries pretty much solve the problem. They let you avoid having to copy your strings to process them.

    Another solution might be to store your string data as std::string‘s all the time. When you need to pass a char* to some API functoin, simply pass it the address of the first character. (&str[0]).

    The problem with this second approach is that std::string doesn’t guarantee that its string buffer is null-terminated, so you either have to rely on implementation details, or manually add a null byte as part of the string.

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

Sidebar

Related Questions

In the android we can see that there is a default google search on
I can't seem to change width in IE7 http://jsfiddle.net/Mkb9n/1/ You can see that all
I can see that GD library is for images. But I can't see differences
I can see that Collections.unmodifiableSet returns an unmodifiable view of the given set but
I can see that the PopUp dropdown of a combobox gets closed if we
In SQL Profiler you can see that very simple updates to a table by
In the following program you can see that each value slightly less than .5
When I run git rm I can see that files were removed in git
I'm using code from other c# app and I can see that in WP7
On the developer page (http://developers.facebook.com/docs/reference/plugins/comments/) I can see that the facebook comment Social plugin

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.