Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Different between const char * and const char const*

Different between const char * and const char const*

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mohindar_kks
    wrote on last edited by
    #1

    Hi, what is different between const char * and const char const *.

    D B S J Z 5 Replies Last reply
    0
    • M mohindar_kks

      Hi, what is different between const char * and const char const *.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      I would like to think the best answer to this question lies in actually coding something up and experimenting with the two to see what can and cannot be done. Has this form of research died off?


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      D 1 Reply Last reply
      0
      • M mohindar_kks

        Hi, what is different between const char * and const char const *.

        B Offline
        B Offline
        baerten
        wrote on last edited by
        #3

        I hope i say it right ... a char * is a pointer on a char-array where you can change all chars into the string. a const char* is a pointer on a string which you can't change, because he is declared or really constant ( for example "test" is a constant string in your memory, you can't change it) and a const char const * is even the pointer constant. That means if the pointer is initializated you can't re-use him const char const *locked = malloc(sizeof(char)*5); ... locked = malloc(sizeof(char)*15); --> DOESN'T WORK I hope i don't have sayed bullshit :)

        1 Reply Last reply
        0
        • M mohindar_kks

          Hi, what is different between const char * and const char const *.

          S Offline
          S Offline
          ShilpiP
          wrote on last edited by
          #4

          Hi , The second way is wrong. we cannot use same type qualifier more than once. A type declaration or definition uses a type qualifier (const, volatile, signed, or unsigned) more than once. This causes a warning with Microsoft extensions (/Ze) and an error under ANSI compatibility (/Za).

          Yes U Can ...If U Can ,Dream it , U can do it ...ICAN

          1 Reply Last reply
          0
          • M mohindar_kks

            Hi, what is different between const char * and const char const *.

            J Offline
            J Offline
            jhwurmbach
            wrote on last edited by
            #5

            mohindar_kks wrote:

            what is different between const $char * and const char const *.

            If you exchange const char const * with const char * const, 'baerten' ist right. The order of words here is only important in that one const has to be before and one after the *


            Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
            George Orwell, "Keep the Aspidistra Flying", Opening words

            1 Reply Last reply
            0
            • D David Crow

              I would like to think the best answer to this question lies in actually coding something up and experimenting with the two to see what can and cannot be done. Has this form of research died off?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              DavidCrow wrote:

              Has this form of research died off?

              Apparently, we're the last generation to know how to do this...

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              1 Reply Last reply
              0
              • M mohindar_kks

                Hi, what is different between const char * and const char const *.

                Z Offline
                Z Offline
                zakkas2483
                wrote on last edited by
                #7

                Hi , I have already given explaination for that please see the post by Shraddha Gautam 8:27 24 Sep '07 Short decription : Pointer To constent const char * and char const * both are same. Constent Pointer char * const Const Pointer to constent const char * const and char const * const both are same. Hiren Thakkar

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups