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.
![Ekran Goruntusu 178](https://i0.wp.com/benswritting.com/wp-content/uploads/2021/12/Ekran-Goruntusu-178.png?w=1200&ssl=1)
After you run your code you have a message saying :
“Return value ignored: ‘scanf’ “
“ ‘scanf’ : this function or variable may be unsafe ”
![errorss](https://i0.wp.com/benswritting.com/wp-content/uploads/2021/12/errorss.jpg?fit=814%2C522&ssl=1)
![errors](https://i0.wp.com/benswritting.com/wp-content/uploads/2021/12/errors.jpg?fit=1024%2C419&ssl=1)
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.
![pragma](https://i0.wp.com/benswritting.com/wp-content/uploads/2021/12/pragma.jpg?fit=686%2C491&ssl=1)
The output after running the code this time
![output](https://i0.wp.com/benswritting.com/wp-content/uploads/2021/12/output.jpg?fit=1024%2C323&ssl=1)
#pragma warning(disable:4996)
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 :
int age;
int birth_year;
printf(” Enter your birthyear “);
scanf(“%d”, &birth_year);
age = 2022 – birth_year;
printf(” your age is = %d\n “, age);
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 좋은 평가 이 답변