The hint that the Linux GCC is not standard C gets,puts function, you can use GCC fgets,fputs to replace gets,puts, the format and change the following: #include "stdio.h"
Main ()
{
Char st[15];
printf ("Input string:\n");
Fgets (St,15,stdin); /*stdin means keyboard input * *
Fputs (st,stdout); /*stdout Standard OUTPUT * *
The reason why GCC does not recommend using the gets and puts functions is that it is clearly written on expert C programming: The Gets function does not check the buffer space, and in fact he cannot check the buffer space, if the caller of the function provides a pointer to the stack, And the gets function reads more characters than the buffer space, and the gets function will happily continue to write the extra characters to the stack, overwriting the original contents of the stack. The early Internet worm took advantage of such a bug The official Manual of C language is strongly recommended to replace the gets function gets (line) completely with the fgets () function; To be replaced by: if (fgets (line,sizeof (line), stdin) ==null) exit (1); This will not overwrite important areas of the stack because others are running the program but Ansic did not remove gets from the standard.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.