Subj : Re: String memory Allocation To : borland.public.cpp.borlandcpp From : maeder Date : Mon Oct 04 2004 12:12 am "M. Finch" writes: > Good explanation guys.... > > So, what is preferred then if it is "recommended" to not use this. I'm > parsing a CSV string. Being that there is even an accronym CSV, it is > pretty common and I'd prefer not to write my own parser if possible. > > I am using it in a multithreaded program and I do seem to have some bugs of > unknown origin. I don't know if this is what is causing it, but I am > interested in getting to a rock-solid program. See Ed Mulroy's post. He writes that the problem I mentioned does not occur on Borland C++ implementations because they guarantee safer behavior wrt reentrancy than what the C++ Standard requires. In new code, on a reasonably Standard compliant implementation, I'd use std::string const input("abc,d,efg"); std::istringstream i(input); std::string token; while (getline(i,token,',')) ; // use token here I'm not quite sure how close to this you can get with Borland C++. I remember 5.0x having an istrstream and a string class. I'm not sure about the getline() function, though. .