Thread: Pass Char ** as Const Char **

  1. #1
    Banned
    Join Date
    Jul 2022
    Posts
    112

    Pass Char ** as Const Char **

    The reason that you cannot assign a char ** value to a const char ** pointer is somewhat obscure.
    Question 11.10

    The reason is somewhat obscure ??

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Did you read the rest of the answer?

    It's "somewhat obscure" because it's not immediately clear why you cannot do that, so it requires a bit of explanation. That explanation is contained on that page that you linked to.

  3. #3
    Banned
    Join Date
    Jul 2022
    Posts
    112
    If you don't know, don't comment.

    I suppose, safety..
    Last edited by Salem; 11-26-2022 at 02:45 AM. Reason: Snipped garbage URL

  4. #4
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    Since you seem to just be trolling people, can you explain why this code doesn't work?

    Code:
    int my_strlen(char *s) {
       char *a = s;
       while(1) {
          s++;
          if(s[-1] == '\0')
              break;
       }
       // A non-MIRSA 2004 compliant comment, just for fun.
       return s-a-1;
    }
    Hope you don't find too much that is abhorrent in there

  5. #5
    Banned
    Join Date
    Jul 2022
    Posts
    112
    @hamster_nz
    I assure you, work is being done.
    So you are wrong..

  6. #6
    Banned
    Join Date
    Jul 2022
    Posts
    112
    So yes these post are relevant.
    They may not be relevant to you, because you can't see my documents.
    That's all.

  7. #7
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Quote Originally Posted by kodax View Post
    If you don't know, don't comment.
    Who says I don't know? I explained exactly why it says the reason is "somewhat obscure"!

    Quote Originally Posted by kodax View Post
    I suppose, safety..
    Basically. It's so that a function can't inadvertently bypass the const-ness of a pointed-to object (a function would have to use an explicit cast to remove the const-ness).

    I think it's way past the time that you should read How To Ask Questions The Smart Way if you want to get anything useful out of this or any other forum and not be rightfully labelled a troll or Help Vampire.

  8. #8
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    Quote Originally Posted by christop View Post
    ...labelled a troll or Help Vampire.
    I've never seen the term "Help Vampire" before...

    So apt for so many cases.

  9. #9
    Registered User
    Join Date
    Sep 2020
    Posts
    425
    Quote Originally Posted by kodax View Post
    @hamster_nz
    I assure you, work is being done.
    So you are wrong..
    Are you saying that that code actually works (and returns the length of the s parameter)?

  10. #10
    Banned
    Join Date
    Jul 2022
    Posts
    112
    @christop
    If you have nothing to add, refrain from commenting.

  11. #11
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Quote Originally Posted by kodax View Post
    @christop
    If you have nothing to add, refrain from commenting.


    Now I know you're trolling us. You ask a question, get relevant answers, and then tell those who answered your question to basically sod off.

    I guess no good deed goes unpunished....

  12. #12
    Banned
    Join Date
    Jul 2022
    Posts
    112
    Hope you don't find too much that is abhorrent in there
    C Traps and Pitfalls
    Amazon.com

  13. #13
    Banned
    Join Date
    Jul 2022
    Posts
    112
    Hope you don't find too much that is abhorrent in there
    Why do you persists in these sub-standard ways..

    Similarly, one may mistake a cursive handwriting with sharpness and mastery,
    Even if it seems conventional and accepted, this a serious contradiction,
    By removing style from a handwriting, the handwriting becomes readable and excellent.

    This is what you fail to realize.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 06-01-2015, 07:13 AM
  2. Replies: 5
    Last Post: 08-31-2013, 07:59 PM
  3. Replies: 9
    Last Post: 08-09-2011, 12:41 PM
  4. Replies: 1
    Last Post: 11-16-2008, 03:46 PM
  5. Assigning Const Char*s, Char*s, and Char[]s to wach other
    By Inquirer in forum Linux Programming
    Replies: 1
    Last Post: 04-29-2003, 10:52 PM

Tags for this Thread