I would like to have your suggestion!
-
My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!
-
My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!
Unless you have a good reason to don't use any of the old CRT string functions. Instead use a string class such as MFC's
CString
or STL'sstd::string
.Steve
-
Unless you have a good reason to don't use any of the old CRT string functions. Instead use a string class such as MFC's
CString
or STL'sstd::string
.Steve
-
The buff is char *. Could tell how to do this strcpy(buff, "#...") with simpliest method? Please help!
Don't use
char*
at all (unless you have a compelling reason). If you're using MFC try usingCString
instead. e.g.CString MyString1 = "Hello"; CString MyString2 = "world"; CString MyString3 = MyString1 + " " + MyString2 + "."; CString MyString4 = MyString3; AfxMessageBox(MyString4);
No explict buffers, no memory allocation, no buffer overruns and no worries.Steve
-
Don't use
char*
at all (unless you have a compelling reason). If you're using MFC try usingCString
instead. e.g.CString MyString1 = "Hello"; CString MyString2 = "world"; CString MyString3 = MyString1 + " " + MyString2 + "."; CString MyString4 = MyString3; AfxMessageBox(MyString4);
No explict buffers, no memory allocation, no buffer overruns and no worries.Steve
-
My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!
In direct answer to your question, to disable the warning and (automatically) to use another function, then include this line in your code:
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
This will automatically substitute secure versions of CRT functions, e.g., it will substitute the secure version strcpy_s for its unsecure counterpart strcpy. The benefit is that you do not need to make any changes to your existing code. See "Secure Template Overloads" at http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx[^]. To read more about secure vs. non-secure CRT functions, see "Security Enhancements in the CRT" at http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx[^]. Mike -
In direct answer to your question, to disable the warning and (automatically) to use another function, then include this line in your code:
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
This will automatically substitute secure versions of CRT functions, e.g., it will substitute the secure version strcpy_s for its unsecure counterpart strcpy. The benefit is that you do not need to make any changes to your existing code. See "Secure Template Overloads" at http://msdn2.microsoft.com/en-us/library/ms175759(VS.80).aspx[^]. To read more about secure vs. non-secure CRT functions, see "Security Enhancements in the CRT" at http://msdn2.microsoft.com/en-us/library/8ef0s5kh(VS.80).aspx[^]. Mike -
My program get a warning warning C4995: 'strcpy': name was marked as #pragma deprecated strcpy(buff,"#test.\r\n"); I should disable the warning or using other function! If using other function, which I should used. I would like to have your suggestion! Please help!
If you want to go with CRT functions, you can go its secure version
strcpy_s
. Refer this[^] for more information. [Edit] This link is already provided in Mike's reply [Edit]Prasad Notifier using ATL | Operator new[],delete[][^]
-
If you want to go with CRT functions, you can go its secure version
strcpy_s
. Refer this[^] for more information. [Edit] This link is already provided in Mike's reply [Edit]Prasad Notifier using ATL | Operator new[],delete[][^]