Like Tree8Likes

Change one element of string pointed by char pointer

This is a discussion on Change one element of string pointed by char pointer within the C++ Programming forums, part of the General Programming Boards category; 1-I really did not understand, otherwise no need to ask you to rephrase. 2-Much better now. I am going to ...

  1. #16
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    1-I really did not understand, otherwise no need to ask you to rephrase.

    2-Much better now. I am going to upload this too.

    3-Well, as you can see in the link in my previous post, I gave them to you, but if you do not like this, I can remove it.

    4-I am not saying that my posts are perfectly stated, so it's ok to be rephrased. The paradigms where there to demonstrate what you can and can not do. I know enough people that would try to do what you can't do. So, I write this code, in order to "prove" that you can't do them

    Anyway, thanks for being pedantic
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  2. #17
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by whiteflags View Post
    A string literal is actually "This" or "this" -- objects of type char[5] -- the data proper
    My turn to rephrase! "The string literal is of type const char[5]". The reason it works for an array is just because even if the syntax is similar it means something completely different. One is
    Code:
    //char* p = "hey";
    const char temp[] = {'h','e','y','/0'};
    char* p = temp; //should really be const char*
    the other
    Code:
    //char a[] = "hey";
    char a[] = {'h','e','y','\0'};

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 01-15-2012, 06:09 AM
  2. Adreess of pointed structure element
    By limp in forum C Programming
    Replies: 1
    Last Post: 06-12-2009, 06:54 AM
  3. How change value pointed to by shared_ptr?
    By 6tr6tr in forum C++ Programming
    Replies: 1
    Last Post: 04-28-2008, 04:45 PM
  4. Problem with passing back pointer pointed to string
    By whichet in forum C Programming
    Replies: 9
    Last Post: 11-21-2007, 07:55 AM
  5. Replies: 5
    Last Post: 10-29-2001, 10:16 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21