question regarding vectors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flavourofbru
    New Member
    • May 2007
    • 48

    #1

    question regarding vectors

    Hi,

    I have a question regarding vectors.
    I have declared a vector of strings as
    vector<string> str;
    and my input into the vector str is:
    str[0] = A
    str[1] = B
    str[2] = C

    is there any method, by which I can join the above three vector elements into one string as "ABC" and push back into the same vector or another vector.

    else
    if my vector consists as follows : str[0] = ABC, is there a function or method by which I can split the string ABC into A, B, C and store it in the same or another vector.

    Thanks!!
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    You should be able to do the first part with simple string concatenation, and the second part with the .substr() function.

    Comment

    Working...