Concatenating: characters->string->vector (string) :: C++

This is a discussion on Concatenating: characters->string->vector (string) :: C++ within the C++ Programming forums, part of the General Programming Boards category; Hi. I would like to know how to concatenate characters into a string that is an element of a vector. ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    Concatenating: characters->string->vector (string) :: C++

    Hi.

    I would like to know how to concatenate characters into a string that is an element of a vector.

    For example:

    string dataTemp("today");
    std::vector<string> vecTemp;

    vecTemp.push_back(dataTemp);

    // I want to add characters into the tring element of vecTemp

    vecTemp[0] += " is Saturday." // Is that right?

    I would like vecTemp[0] to be "today is Saturday."

    Thanks,
    Kuphryn

  2. #2
    Unregistered
    Guest
    The += operator is overloaded for strings so it should work in theory at least.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. Thanks.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  3. How do you check how many characters a user has entered?
    By engstudent363 in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 06:05 AM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. Concatenating characters
    By fkheng in forum C Programming
    Replies: 4
    Last Post: 08-22-2003, 09:48 PM

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