I've been told there is memory corruption for buf.str().c_str(): void myFunc() { std::stringstream buf; buf << "some string"; const char *data = buf.str().c_str(); SomeFunc(data, strlen(data)); //do something else } Can someone explain why?