vector/array to string problem

This is a discussion on vector/array to string problem within the C++ Programming forums, part of the General Programming Boards category; Hi, I have an array of strings which i'm trying to read one by one into a string. The array ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    12

    vector/array to string problem

    Hi,

    I have an array of strings which i'm trying to read one by one into a string. The array is filled correctly, and has all the elements I want. Here's the code I have to read it into a string:

    string f = "";

    for(int i = 0; i < 45; i ++)
    {
    if(vs[i +1] == "")
    {
    f += vs[i];
    }
    else
    {
    f += vs[i] + ", ";
    }
    }
    As you might have guessed, i'm trying to construct an SQL query that gets passed to another method. The last element in the array cannot have a ", " next to it b/c of the query structure.

    anyway, the string f gets messed up at one point. It just wont' accept any more strings from the array after a while.

    This is all happening inside a class with the header "__gc" -- a managed C++ class. When i tried this same thing in a regular old unmanaged Main method, it worked fine. I'm so confused...can someone please tell me what's wrong?

    The array is made up of std::string, and f is also std::string
    thanks

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    12
    I apologize -- i was being dumb, i figured out my problem ( *smacks self in head*)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance Hierarchy for a Package class
    By twickre in forum C++ Programming
    Replies: 7
    Last Post: 12-08-2007, 04:13 PM
  2. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 03:40 AM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM

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