1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

can anyone explain this.......!!!!!!!!!!

Discussion in 'C' started by indian.21987, Aug 20, 2007.

  1. indian.21987

    indian.21987 New Member

    Joined:
    Aug 19, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Difference between
    const char*ptr and
    char *const ptr
    please give detailed explaination with examples
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    The first one says that ptr is a pointer to a const char, but that the pointer can be modified.

    The second says that the ptr is const, but the char is modifiable.

    If that isn't detailed enough, or exemplar enough, let me recommend your documentation, or Google.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    const char* ptr means "ptr points to a char that is constant" — that is, the char can't be changed via ptr.
    char * const ptr means "ptr is a constant pointer to a char" — that is, you can change the char via ptr, but you can't change the pointer itself.
     
  4. indian.21987

    indian.21987 New Member

    Joined:
    Aug 19, 2007
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    got it

    thanks a lot
     

Share This Page