let's say i have a data file i want to write:
most of you can see the problem here: name has a space in it. what i want to do is seperate each field with a comma (or some other distinct marker). is there a manipulator that can automatically end everything with a character of my choice?Code:float gpa=3.45654; int cost=45430; string name; name = "two words" ofstream out("out.file"); out << gpa << cost << name; out.close(); /* .... */ ifstream in("out.file"); in >> gpa >> cost >> name; in.close();
//edit: for instance:
out << gpa << cost << name;
and input should act like this:
in >> gpa >> cost >> name;
it should take a float, throw away the comma, get the integer, throw away the comma, then get the whole string, regardless of spaces, but only until it hits a comma (or the end of the string).
theoretically, anyway. i don't know if this is possible even with changing the iostream and/or the string classes