Thread: concatenate string || better way

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    You are mistaken. result is an array of 200 char, not a pointer to char. It is true that in many cases it is implicitly converted to a pointer to its first element, but in this case that does not happen, and since you cannot assign to an (existing) array, you get that error.

    The thing is that you don't need this assignment in the first place: the result is already written to the first argument, i.e., it is written to your result array.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Registered User
    Join Date
    Oct 2013
    Thank you. I got it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-25-2020, 09:11 AM
  2. I can't concatenate a string
    By qqsszz in forum C Programming
    Replies: 9
    Last Post: 06-29-2018, 03:55 PM
  3. How do you concatenate a char to a string
    By sigur47 in forum C++ Programming
    Replies: 15
    Last Post: 02-20-2012, 01:45 PM
  4. Concatenate string and int
    By millsy5 in forum C Programming
    Replies: 1
    Last Post: 01-28-2010, 04:43 AM
  5. Concatenate a String?
    By sharkbate24 in forum C++ Programming
    Replies: 7
    Last Post: 01-02-2009, 05:16 PM

Tags for this Thread