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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:57:52+00:00 2026-06-17T18:57:52+00:00

I have an API for the functions, say: void func (const char** s,const size_t*

  • 0

I have an API for the functions, say:

void func (const char** s,const size_t* ss);

I.e. the function gets the const array of null terminated strings [s] and their sizes [ss].
I get the strings during run-time and not aware about their amount.
What I thought to do is to define vector<char*> vS – insert the strings to it and define vector<size_t> vSS – insert the strings sizes to it.
Eventually I should transfer vector<char*> vS to const char**
and vector<size_t> vSS to const size_t*.
I am aware that exists a trick &vS[0] / &vSS[0].The problem is that the above generates char** and size_t* ss respectively.But I am missing const.
How the issue could be solved?

  • 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-17T18:57:53+00:00Added an answer on June 17, 2026 at 6:57 pm

    If you are passing params to function (and not trying to pass results back in the arguments), than non-const’ness is not a problem: you may use char * anywhere where cont char * is required.

    But you have problems with double pointers – const char **, etc. They are not converted implicitly because it can lead to const violation. You can read an explanation in C++ FAQ Light.

    In your case you can just create a vector<const char*>, as @aschepler said.

    BTW, const char** is not “const pointer to pointer to char”, but “pointer to const pointer to char”, you have to add another const if you want to ensure that function doesn’t change the outer pointer contents. const char * const * or char const * const *, which is the same – pointer to const pointer to const characters.

    (BTW, reading right-to-left relly helps when dealing with multiple consts: try it with the last expression from the previous paragraph. And yes, you can add another const at the end of this exprssion to get “const pointer to const pointer to const char”).

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

Sidebar

Related Questions

Say I have a function that receives a byte array: void fcn(byte* data) {
I have a function definition in my VC++ Win32 DLL DEMO2_API void ProcessData(char* i_buff,
I have a problem with a function ( setLayerType(LAYER_TYPE_NONE, null) ) available in api
Say I have a template function that accepts variable arguments and calls other functions
I have my php app working fine, performing some other Graph API functions. However,
I have code that uses Win API function RegSaveKeyEx to save registry entries to
We have a moderate size (40-odd function) C API that needs to be called
I have a function that uses the SharePoint api so the method SPUtility.GetLocalizedString is
I have a function that uses the Google Blobstore API, and here's a degenerate
I have the following function in a PHP script, which returns and API call:

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.