scanf output error

Asked 2 years ago, Updated 2 years ago, 77 views

#include<stdio.h>
int main() {
    int n;
    scanf("%d",&n);
    printf("%d",n);

    return 0;
}

I don't think there's a problem with the code, but it keeps printing.

Severity code descriptionProject file line display error status
This function or variable may be unsafe. 
Consider using scanf_s instead.  To disable deprecation, use _CRT_SECURE_NO_WARNINGS. S
ee online help for details.

If you use scanf_s?, the output window will appear, but the value of 15 should appear, but nothing will appear Help me, gentlemen.

scanf c

2022-09-20 14:55

1 Answers

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

Google translator
C4996 'scanf': This function or variable may not be safe.
We recommend using scanf_s instead. To disable support disruption 
Use _CRT_SECURE_NO_WARNINGS. NS
For more information, see Online Help.

If you want to use scanf, please define #define_CRT_SECURE_NO_WARNINGS

https://docs.microsoft.com/en-US/cpp/c-runtime-library/security-features-in-the-crt?view=msvc-160

scanf_s requires one more parameter, unlike scanf.

Unlike scanf and wscanf, scanf_s and wscanf_s require you to specify 
buffer sizes for some parameters.

https://docs.microsoft.com/en-US/cpp/c-runtime-library/reference/scanf-s-scanf-s-l-wscanf-s-wscanf-s-l?view=msvc-160


2022-09-20 14:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.