I have been coding a GUI program as a MySQL database manager/utility...

The idea of the section I am focusing on is, your enter a guild's name, and it queries the database and displays the guild's info in a textbox. As a test I have used this query:

SELECT * FROM `guilds` WHERE `tag` = 'ARD'

It successfully queries the database for the guild I am testing on, and displays this in my textbox:


(Those are the value from my database)

I am trying to store each value (description, TAG, so on..) to a separate char/string. I have tried using the getline and that just stores them all (on different lines) to a single char.

std::string a;
std::string b;
std::string c;

(above declared at the top)

a = string(newdelim)+string(row[i]);
stringstream stream(a);
while(getline(stream, c, ','))
       b = c+"\n";

(then goes on to write d to the texbox)

The value char "newdelim" is the delimiter, and the char "row" is the mysql row, both written into the void function.

This is the code I tried using for testing getline().

I have searched over google, the forums, and asked a few buddies on MSN, but alas, no answer to my question:
How do I use a delimiter to seperate a char/string into separate values?

I need to split a string or char with a delimiter and store each value to a new char.
I have tried getline, and that just stores them on the same char.

Help? :)

(Sorry if I made this unclear/repeated things too much, I haven't... I haven't really slept.)

Used code tags on first post :)
7 Years
Discussion Span
Last Post by Ardvarks

If I read that correctly, if I use something like that, words[number] would be each value?


If I read that correctly, if I use something like that, words[number] would be each value?

Everything between the delimiters is stored in a vector.
For example when you have this string: "first,second,third" and you set the comma as a delimiter, then you'll get a vector with these elements:


I don't personally use vectors all too much, but thanks! Up'd your reputation, it works fairly well for now.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.