Thread: stripy Error in Visual Studio 2013

  1. #1
    Registered User
    Join Date
    Jul 2015
    Posts
    1

    stripy Error in Visual Studio 2013

    I keep getting the error below when I try to compile my code.

    1>d:\c++ examples folder\mystring\mystring\mystring.cpp(46): error 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 (x86)\microsoft visual studio 12.0\vc\include\string.h(112) : see declaration of 'strcpy'

    I have gone in and set the "Treat warning as errors to NO" and still get the same error.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    3,749
    IIRC, you need to add this line to your program.
    I do NOT remember if before the includes or right after the include is best. I would try after the includes and if that fails add it before the include. Been about 10 years since I used MSVC as an compiler.

    Code:
    #define _CRT_SECURE_NO_WARNINGS
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,485
    Actually you would put that #define before any #include directive.

    But the bigger question, since this is the C++ forum is why are you using C-strings instead of C++ strings which would alleviate the need for this macro.


    Jim

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,514
    The right place to put that in the project configuration such that the compiler will be invoked with /D _CRT_SECURE_NO_WARNINGS as an option. Look for a setting that reads "preprocessor definitions" or something like that.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jimblumberg View Post
    But the bigger question, since this is the C++ forum is why are you using C-strings instead of C++ strings which would alleviate the need for this macro.
    This. Why are you using strcpy in the first place?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my Visual Studio Ultimate 2013 is messed up
    By fouzimedfouni in forum C Programming
    Replies: 14
    Last Post: 02-08-2015, 10:59 PM
  2. Visual Studio Just-In-Time Debugger Error
    By JudgeFudge in forum C++ Programming
    Replies: 1
    Last Post: 11-10-2010, 10:38 AM
  3. error configuring Qt for Visual studio
    By heisel in forum C++ Programming
    Replies: 10
    Last Post: 10-02-2009, 09:16 AM
  4. Visual Studio C++, syntax error : ']'
    By Sparrowhawk in forum C Programming
    Replies: 26
    Last Post: 10-15-2008, 03:14 AM
  5. Uninstall Visual Studio Error
    By MrWizard in forum Tech Board
    Replies: 10
    Last Post: 09-08-2002, 04:34 PM