#include <iostream> using namespace std; void someFunction(const char* str) { cout << "buffer :" << str << endl; std::string abc(str); abc = abc.substr(5); cout <<"After manipulation :" <<endl; str = abc.c_str(); //will this create memory leak? } int main() { std::string str = "My file is this one"; const char* c = str.c_str(); cout << c << endl; someFunction(c); return 0; }
c_str()
std::string
Quote://will this create memory leak?
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)