On 03.01.2017 15:29, McLeod, John wrote: > What about the std::string function c_str? It returns a non-modifiable > pointer to the null terminated data in the string?
This function (std::string::c_str) provides a non-modifiable pointer and the pointer is only valid as long as the string exists. So you can't use the pointer outside of the context of the string. So the safe_copy() function serves two purposes. It copies a string into a new char array to make it modifiable and usable outside of the string context. Another solution would be to only use strings and use c_str() locally when it is needed and not pass around pointers to char arrays. Regards Christian _______________________________________________ boinc_dev mailing list [email protected] http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev To unsubscribe, visit the above URL and (near bottom of page) enter your email address.
