<25> "Mastering" fget (), fputs () function use/pros and cons

Source: Internet
Author: User

"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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.