Search code examples
cpragma

C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS


I want to solve this problem without "#pragma warning (disable:4996)" please help me. I tried many things. I think it may have problem with visual studio.


Solution

  • Use scanf_s() and make the necessary other changes, or #define _CRT_SECURE_NO_WARNINGS. Basically, read the error message and do what it suggests.

    Note that scanf_s() requires extra arguments for the lengths of “string” arguments.