"Warning:this program uses get (), which is unsafe," was used today in C code. ", and then this app can run, boring I started to check the information, why gets () will be unsafe.
Through Google to consult the questions and answers of predecessors, this is the case.
Gets () This function has only one parameter, which is the pointer to the character buffer, and does not specify the length of the buffer, which is the size. When you enter a long, long string, the Get () function will store each character in the stack (STATCK), so that when the string is large it causes the program to terminate unexpectedly. The advice given by seniors is to use the fgets () function instead of get ().
Example:
Use the gets () char buffer[4096];gets (buffer);//Use Fgets () to replace the gets () char buffer[4096]; Fgets (buffer, (sizeof buffer/sizeof buffer[0]), stdin);
Reference URL:
1, StackOverflow
C uses the gets () hint Warning:this program uses gets (), which is unsafe.