'strcpy' error and warning

Posted by Leejo on Stack Overflow See other posts from Stack Overflow or by Leejo
Published on 2010-04-22T17:20:05Z Indexed on 2010/04/22 17:23 UTC
Read the original article Hit count: 379

Filed under:

I'm getting a 'strcpy' error and warning for the following lines:

_tcscpy(strCommandLine,_T("MyProgram.exe /param1"));

_tcscpy(strApplicationName,_T("MyProgram.exe"));

Not sure why I'm getting a 'strcpy' error or warning since I'm not using 'strcpy'. The only lines related to this is:

LPCTSTR strApplicationName;
LPTSTR strCommandLine;
_tcscpy(strCommandLine,_T("MyProgram.exe /param1"));   //warning is on this line     
_tcscpy(strApplicationName,_T("MyProgram.exe"));       //error is on this line

The output is:

1>c:\documents and settings\X.X\my documents\sandbox\sample.cpp(52) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

1> c:\program files\microsoft visual studio 8\vc\include\string.h(74) : see declaration of 'strcpy'

1>c:\documents and settings\X.X\my documents\sandbox\sample.cpp(53) : error C2664: 'strcpy' : cannot convert parameter 1 from 'LPCTSTR' to 'char *'

1> Conversion loses qualifiers

Any ideas on what this could means?

These are my headers: iostream windows.h stdio.h tchar.h winnt.h

© Stack Overflow or respective owner

Related posts about visual-c++