6
votes
3answers
2k views

What performance can we expect from std::string's c_str()? Always constant time?

I've been doing some needed optimizations lately. One thing I've been doing is changing some ostringstreams -> sprintfs. I'm sprintf'ing a bunch of std::strings to a c style array, ala char foo[500]; ...