Question link: http://poj.org/problem? Id = 2632
Let's start by saying that things went smoothly after 1Y yesterday and things were not published again until this afternoon. It's really like a sea of questions. From now on, the AC is a passer-by
1) fflushThe compiler stipulates that Fflush is used to flush the output stream, and there is no provision for the input stream, that is, the fflush (stdin) result is unknown.This is the VC under the C program, Fflush (stdin) effective, VC write C +
#include #include
int sum;//sum is a global variable
Main (){int i;//i is a local variable
sum = 0;for (i = 1;i {printf ("The value of I is%d/n", i);Fflush (stdout);//flush the buffersum + = i;}printf ("The sum is%d/n", sum);Exit (0);//terminate
The traditional U N I x implementations have buffer memory in the kernel, and most disk I/O is done through caching. When the data is writtenTo a file, the data is typically copied from the kernel to the cache, and if the cache is not already full,
FF (stdin) refreshes the standard input buffer and discards anything in the input buffer.
Fflush (STDOUT) refreshes the standard output buffer and prints the output buffer to the standard output device.
When the scanf () function receives input
The following code:
#includeusing namespace std;int main(){ int m; while(1==scanf("%d",&m)) { puts("OK"); } system("pause");}
This code can be a correct loop, that is, the input integer outputs OK, and then waits for the next input to
Reprinted from (http://www.cplusplus.com/reference/clibrary/cstdio/fflush) Int fflush (File * stream );
Flush stream
If the givenStreamWas open for writing and the last I/O operation was an output operation, any unwritten data in the output buffer
Today with
ftruncateTruncation of the file, but how can not achieve the expected effect, truncated after the contents of the file is miscellaneous, and the file size is kept original.
add fflush () and Rewind () after OK.
Here is the test code:
Recently read the LEVELDB source code, as a guarantee of reliability of the KV database its data and disk interaction is extremely critical, which involves a lot of memory and disk synchronization operations and policies. In order to deepen
# Include
# Include
# Include
# Include
# Include
Typedef struct com {// char num [10]; long num; char name [10]; Long Count; // char amount [10]; // char from [20]; // char stockdate [10]; struct com * Next;} com; # define Len sizeof
Today, ftruncate is used to truncate the file, but it cannot achieve the expected results. After the file is truncated, the content is complex and the file size remains unchanged.
After adding fflush () and rewind (), OK.
The following is the test
Phpfflush function & amp; nbsp; fflush (in PHP4 & amp; ldquo; 4.0.1, PHP5) fflush-refresh the output to a file description Boolean fflush (resource $ processing) this function is used to write the file handle pointed to by all buffered output
Reprinted from: http://blog.chinaunix.net/u3/99423/showart_2100968.html
I have made many mistakes in the scanf function, and I have also seen mistakes made by others. Remember to remind myself not to repeat the same mistakes. If it is useful to you,
Phpfflush function. Phpfflush function fflush (4.0.1, PHP5 in PHP4) fflush-refresh the output to a file description Boolean fflush (resource $ processing) this function forces the php fflush function to write all buffer outputs
Fflush("= 4.0.1, PHP
Today, we can see a friend of the C version of Cu code and the output result.# Include
Main (){Printf ("1 .");Sleep (2 );Printf ("2 .");Sleep (2 );Printf ("3 .");Sleep (2 );Printf ("4 .");Printf ("OK/N ");}% GCC test. c%./A. Out1.2.3.4. OK
Sleep
[Php kernel] ---- file system functions are used in common files. Today, I talked to my colleagues about the function of fflush. I thought that the file system function of php should be built on the standard IO Library of the system. therefore, the
Linux,unix has buffer cache or page caching in the kernel, most disk I/O is buffered and delayed write technology is used.Sync: Put all the modified cache into the write queue, then return, do not wait for the actual write disk operation to endFsync:
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.