"Mastering" fget (), fputs () function use/pros and cons
1, fgets () The function a file operation-related function temporarily uses this function to receive a string from the keyboard quotient, saving to the array the method that originally received the string to be saved to the arrayCharstr[ -]; 1) scanf ("%s", str);//Cons: Cannot receive spaces 2) gets (str);//Pros: You can receive spaces//There's going to be a warning, unsafe.//Unsafe : For example the array length is 50, if we enter the//the length is exactly 50, at this point 50 characters are all stored in a//Array, there is a problem because there is no space to hold the string terminatorfgets () is a safe string to receive a functionCharch[5];//If you use Fgets, the maximum number of visible characters in the array is 4//will automatically store the last element of the array.fgets () use format: fgets (array name, array length, stdin); Fputs (); is also a file operation related to the format of the function: fputs (array name, stdout);
<25> "Mastering" fget (), fputs () function use/pros and cons