This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
std::setlocale(...) return value ??
- From: Papa <papa at arbolone dot ca>
- To: gcc-help Mailing List <gcc-help at gcc dot gnu dot org>
- Date: Thu, 4 May 2017 04:33:36 -0400
- Subject: std::setlocale(...) return value ??
- Authentication-results: sourceware.org; auth=none
According to the C++ Reference setlocale(...) returns a 'char*',
however, when trying to assign this function's return value to another
'char*', it creates an run time error.
Here is my example:
<snip>
void jme::Locale::setGlobalLocale(const std::string& str){
char* arg = new char[str.length()+1];
strcpy(arg, str.c_str()); // const char* to char* -- Works
char* cp = new char[1024];
strcpy(cp, std::setlocale(LC_ALL, arg)); // char* to char* --
Does not work ??
delete arg;
delete cp;
}
</snip>
The code compiles, but as I said before it does not run.
What am I missing? How can I solve this problem?
--
ArbolOne.ca
Using FireFox and Thunderbird.
ArbolOne is composed of a group of students and volunteers
dedicated to providing free services to charitable organizations.