About the cleanup of C-language buffers

Source: Internet
Author: User

The problem with the input and output stream has not been clear.

Do OJ today, involving the input of strings

Here are three types of buffer cleanup issues

Law One:

Fflush (stdio);
View Code

According to Baidu experience, this usage applies only to the VC6.0 version

Law II

Setbuf (Stdio,null);
View Code

The second method is to set the standard input stream to an empty buffer

Fahsarm

Chartemp;//The wording of a while(temp = GetChar ()! ='\ n'&&temp!=EOF)//notation Two while(1) {Temp=GetChar (); if(temp=='\ n'|| temp=='EOF')         Break;} 
View Code

This approach is to use a loop that always reads the characters in the buffer

Written in two ways.

The first one is cool, but it's very eye-reading.

The second is simple and straightforward, I prefer the second kind

--------------------------------------------------------------------------------

This is my first technical blog, although very irregular, but everything at the beginning of the difficult, this should be a freshman should understand things, now a senior to solve, ashamed.

It looks like the experience of Baidu, but it is summed up once, it is always good.

About the specific parameters of each function, call, I should go to read a technical document, to a good summary of, but prepare for the second-round interview, Time Rush, after the empty again to complement the full of robustness.

About the cleanup of C-language buffers

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.