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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:31:23+00:00 2026-06-09T08:31:23+00:00

Apparently it’s good practice to use const unless something is meant to be mutable,

  • 0

Apparently it’s good practice to use const unless something is meant to be mutable, but how far do you go? If I have an array of strings, should my function signature include this?

char const * const * const my_strings

I’m not going to be modifying it whatsoever, so it’s a constant pointer to the first element of an array of constant pointers to the first elements of arrays of constant characters. That’s a mouthful, and the code is nearly unreadable. All this is a simple data structure like argv.

I feel as though const should be default and there should be a mutable keyword.

Do you generally just one of those consts? What’s the point of that then, if you can still easily change it by dereferencing more or less?

  • 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-09T08:31:24+00:00Added an answer on June 9, 2026 at 8:31 am

    I would generally use two of the three consts:

    const char *const *my_strings;
    

    Sometimes I would use all three, but in my opinion the last one is the least important. It only helps analyze the code that uses the variable my_strings, whereas the other two help analyze code that has any pointer to the array pointed to by my_strings, or to the strings pointed to by the elements of that array. That’s generally more code, in several different places (for example the caller of a function and the function itself), and hence a harder task.

    The code that uses the variable itself is limited to the scope of my_strings, so if that’s an automatic variable (including a function parameter) then it is well-contained and an easier task. The help provided by marking it const might still be appreciated, but it’s less important.

    I would also say that if char const * const * const my_strings is “nearly unreadable”, then that will change when you have more practice at reading C, and it’s better to get that practice than to change the code. There’s some value in writing C code that can be easily read by novices, but not as much value as there is in getting some work done 😉

    You could use typedefs to make the variable definition shorter, at the cost of introducing an indirection that will annoy many C programmers:

    typedef char const *ro_strptr;
    ro_strptr const *my_strings;
    

    For whatever reasons, C programmers often want to see as much as possible of a type in one place. Only when the type gets genuinely complicated (pointer-to-function types) can you use a typedef solely to abbreviate, without half-expecting that somebody will complain about it.

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

Sidebar

Related Questions

Apparently many people have run into this problem, but I have yet to be
Apparently I've done something I'm not aware of All my classes now have warnings
Apparently, I have completely misunderstood its semantics. I thought of something like this: A
Apparently I'm missing something obvious here, but would appreciate a quick example. I've got
Apparently xrange is faster but I have no idea why it's faster (and no
Apparently Mac keyboards don't have an Insert key (or maybe they do but I
Apparently, I'm missing something fundamental. I'm having a problem with formatting the value of
Apparently the font Arvo is supposed to work fine in IE, but I can't
Apparently there is no predefined list available in .net. I'd like to use a
Apparently in VS2008 SP1 there's an option under Publish | Options to have 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.