One of the problems encountered after the installation of the programing language C in Microsoft Visual Studio sometimes the number lines are not displayed automatically which you have to do it manually.
To solve this we are going to write a program:
Where we are going to write a program where we are going to ask someone’s age by asking his birth year.
After you run your code you have a message saying :
“Return value ignored: ‘scanf’ “
“ ‘scanf’ : this function or variable may be unsafe ”
To solve this you have to add this code #pragma warning(disable:4996)
The green line in the scanf code will still but your code will run without any problem.
The output after running the code this time
To turn off the warning within a file for everything that follows, use the warning pragma.
If you want you can copy the code from here :
printf(” Enter your birthyear “);
age = 2022 – birth_year;
printf(” your age is = %d\n “, age);
3 thoughts on “Scanf is not working in Microsoft visual studio code (Solution )”
Thank you so much,
I’ve been having this problem and couldn’t find a solution anywhere on the internet.
Would you mind giving an explanation as to how this works?
The only thing you have to is to add this : #pragma warning(disable:4996)
on the top and it will work.
Pingback: Visual Studio Scanf | How To Solve Scanf() Error Problem In Microsoft Visual Studio 11784 좋은 평가 이 답변