#include
Int main ()
{
Char a, [8].//define length is 8
Size_t I;
I=_snprintf (a, 13, "% d" 012, 123456789);//write length of 12 characters
The printf (a);//print to window shows 000123456789
printf("\n");
system("pause");
return 0;
}
Define a length of only eight, run results either an error or print only eight characters before yes, why is printed to the window of super-long character?
CodePudding user response:
Char a [8] data overflow will affect other variables such as size_t ICodePudding user response:
Recommend using _s function, _snprintf_s