解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误

//解决VS2013中出现类似于error C4996: 'scanf': This function or variable may be unsafe的安全检查错误 https://blog.csdn.net/dan15188387481/article/details/49622783/


//#pragma warning( disable : 4996)
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
# include <string.h>
# define DENSITY 62.4
#define ESC '\065'

#include <stdio.h>
#include <limits.h> // integer limits
#include <float.h> // floating-point limits

int main(void)
{
/****************
float aboat = 32000.0;
double abet = 2.14e+9;
long double dip = 5.32e-5;

printf("%f can be written %e\n", aboat, aboat);
printf("%f can be written %e\n", abet, abet);
printf("%f can be written %e\n", dip, dip);

float toobig = 3.4E38 * 100.0f;
printf("%e\n", toobig);

char beep = '\007';
//char some = '\032';
char some = '\32';
printf("beep is %c\n", beep);
printf("some is%c space\n", some);

//转义序列
float salary;
printf("aEnter your desired monthly salary: ");
printf(" $_______\b\b\b\b\b\b\b");
scanf("%f", &salary);
printf("\n\t$%.2f a month is $%.2f a year.", salary, salary * 12.0);
printf("\rGee!\n");

int f = 4;
int g = 5;
float h = 5.0f;
printf("%d\n", f, g);
printf("%d %d\n", f);
printf("%d %f\n", h, g);

**************/

 

/*********************************
float weight, volume;
int size, letters;
char name[40];

printf("Hi What's your first name?\n");
scanf("%s", name);
printf("%s, what's your weight in pounds?\n", name);
scanf("%f", &weight);
size = sizeof(name);
letters = strlen(name);
volume = weight / DENSITY;

printf("Well, %s, your volume is 2.2%f cubic feet.\n", name, volume);
printf("Also, your first name has %d letters, \n", letters);
printf("and we have % d bytes to store it in.\n", size);

printf("ESC %c \n", ESC);
printf("%c \n", '53');



printf("Some number limits for this system:\n");
printf("Biggest int: %d\n", INT_MAX);
printf("Smallest long long: %lld\n", LLONG_MIN);
printf("One byte = %d bits on this system.\n", CHAR_BIT);
printf("Largest double: %e\n", DBL_MAX);
printf("Smallest normal float: %e\n", FLT_MIN);
printf("float precision = %d digits\n", FLT_DIG);
printf("float epsilon = %e\n", FLT_EPSILON);

**********************************/

/**********************************
int bph = 212;
int rv;
rv = printf("%dF", bph);
printf("The printf() function printed %d characters.\n", rv);

printf("Here's the newest way to print a"
" long string.\n");

char aaa;
scanf("%c", &aaa);
printf("%c", aaa);
**********************************/

int n = 0;
size_t intsize;
intsize = sizeof(int);
printf("n=%d, n has %zd bytes; all ints have %zd bytes.\n", n, sizeof n, intsize);

printf("-11%%-5 = %d", -11 % -5);

return 0;
}

posted @ 2021-09-28 10:50  Thermo  阅读(85)  评论(0编辑  收藏  举报