Thread: how get get rid of this warning?

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    how get get rid of this warning?

    when i compiled in "code blocks" compiler my
    code showed no wornings
    but when i compiled with visual studio 2005 i got 4 warnings of this type:

    warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

    for each warning i get my grade cut off by a significant number
    how to fix this??
    Last edited by transgalactic2; 12-15-2008 at 08:57 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Go to Project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor

    Then in the "Preprocessor Definitions" field set _CRT_SECURE_NO_WARNINGS so as to disable those needless warnings.
    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

  3. #3
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    so there is no problem??
    i thought maybe i use long variable
    and do %d
    in the scanf
    or the opposite case when i enter %ld
    in the scanf
    but the variable is integer
    ??

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    but i checked
    for every integer i wote %d in the scanf
    and in long i got %ld in the scanf

    so this is not a sign for the program to crush in some case?
    Last edited by transgalactic2; 12-15-2008 at 09:10 AM.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    The problem is that you are using scanf(), and the Microsoft compiler has an arguably safer version that is non-standard and which it suggests to you by default through irritating warnings.
    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

  6. #6
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM