Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi everybody
It is interesting, I could do any conversion in MFC Ver.6, But I receive compiler error on itoa!
Could you please give me a sample.

What I have tried:

Every time I get POSIX Error and _itoa give me SECURE Error.
Posted
Updated 7-Sep-20 8:20am
v2

To convert an Integer into a CString, the best way would be:


C++
CString MyString;
int MyInt;

MyString.Format(L"%d",MyInt);


Another way is to use the std library's to_wstring[^], and then cast the result to CString.

In that case, your code will be:

C++
MyString = (CString)(std::to_wstring(MyInt).c_str());
 
Share this answer
 
Since you have not given us any information about your problem the code you are using, or the actual error message, the best I can do is suggest a reading of _itoa, _itow functions | Microsoft Docs[^].
 
Share this answer
 
What about the documentation[^]?

I've underlined it for you:

Because of their potential for security issues, by default, these functions cause deprecation warning C4996: This function or variable may be unsafe. Consider using safe_function instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. We recommend you change your source code to use the safe_function suggested by the warning message. The more secure functions do not write more characters than the specified buffer size. For more information, see _itoa_s, _itow_s functions.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900