Severity code description Project file line prohibits display status error C4996'strcat': This function or variable may be unsafe. Consider using

Series of articles catalog

Base element 1.
The circuit design 3.PCB design 4. The welding element 6. programming 9. testing standards




Phenomenon: The severity code indicates that the status of the project file line is prohibited.
Error C4996'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Solution: Change the sentence strcat(des, src); to strcat_s(des, src);

Reason: because strcat(des, src); is not safe to write in this way. If this program is executed dynamically, the program is not sure whether the character array des is large enough. If you are really negligent, define the first character array than The second character array is small, so the program runs, the buffer overflow will occur, once it overflows, it may overwrite the originally useful data, which is a very dangerous behavior.
So the compiler is very smart to tell us that it is not safe to write this way, and use the function strcat_s(des, src) instead. This function is provided by Microsoft and does not support cross-platform. The -s type is provided by Microsoft. Yes, he will let you specify the size of the buffer, he will judge that if the second character array is really spelled, the space of the first character array is not enough, if it is not enough, it will directly call the police, and it will not cause a buffer overflow This situation.

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44407238/article/details/113829113