Gets (char buffer[]) reads a line from the standard input and strips out the newline character, adding the ' + ' characters to the end of the string, writing to the buffer
Success returns the address of buffer, error or end of file returns a null pointer, using the null representation of Stdio
Fgets (char buffer[], int num, file * f) reads num-1 characters from the specified file F, strips out line breaks , and adds '% ' characters at the end , written to buffer
scanf (const char * format [, argument]) is more based on getting the word than getting the string, adding the ' + ' character at the end of the string, if the width is specified, the string length is N + 1, and the reason for stopping reading the string ends:
1. first non-whitespace character encountered
2. if width is specified, stop reading after reading the specified width
Returns EOF or a successfully read variable
FSCANF (FILE *stream, const char *format [, argument])
Return with scanf
String printing is stopped when encountering '/'
Puts () automatically adds ' \ n ' line break at the end of the string
Fputs ()
printf ()
fprintf ()
strcpy, Ctrcat, sprintf, gets can easily cause buffer overflow, the culprit is not check the variable length
Get (char *buffer) reads a line of text from a user input from a standard input, which does not stop reading the text until it encounters an EOF character or a newline character, that is, gets () does not perform bounds checking at all, so it is always possible to overflow any buffer with get (). Never use this function , unsafe, no limit on the number of characters entered, if exceeding buffer will cause the program to fail, you can use the fgets () function instead
Do not use the following code:
Char buf[1024x768];gets (BUF);
Use the following code instead:
Char buf[bufsize];fgets (buf, BUFSIZE, stdin);
strcpy () copies the source string to a buffer, does not specify the exact number of characters to copy, the number of characters copied directly depends on the number in the source string, and if the source string happens to come from user input and does not specifically limit its size, it is possible to get into big trouble
1. If you know the size of the destination buffer, you can add an explicit check
if (strlen (SRC) >= dst_size) { /**/else { strcpy (DST, SRC);}
2. Using the strncpy () function
strcpy, Strcat, sprintf, scanf, sscanf, fscanf, vfscanf, vsprintf, vscanf, vsscanf, Streadd, strecpy, Strtrns,
C language-string manipulation functions