what is meant by flushll() in c programming?



what is meant by flushll() in c programming?..

Answer / chauhan rakesh botad

The flushall function flushes all streams.
flushall clears all buffers associated with open input
streams and writes all buffers associated with open output
streams to their respective files. Any read operation
following flushall reads new data into the buffers from the
input files. Streams stay open after flushall executes.

Return Value

flushall returns an integer the number of open input and
output streams.

This is used to clear the buffer memory...for eg.we use
flush(stdin) before the getch() command and scanf command so
as to clear the memory space...sometimes it happens that
getch() takes 'enter' as a character ...to avoid this we use
the flush functions.

flushall clear any data in stream. it doesnt mean data gets
lost, instead all buffered data process and sent to target
output source.
like writing to a file using filestread and if we have write
some data in stream which is in buffer but not written in
file. as you call flushall it will write all data to file
and then clear the buffer(i.e memory space).

The fflush() and flushall() functions in the C run-time
library do not write file changes directly to disk. These
functions flush the file buffers provided by the library;
they do not flush the buffers the MS-DOS, OS/2, or Windows
NT operating systems provide at the system level. For
example, if an application calls fflush() but MS-DOS does
not write its buffers to disk before a system crash (or
equivalent event), information may still be lost. To address
this situation in MS-DOS, use the _commit() function after
you call fflush() or fflushall(). Calling _commit() causes
the operating system to flush to disk the buffer associated
with a file handle.

The OS/2 operating system provides two separate functions,
depending on the installed version of OS/2. In 16-bit OS/2
(versions 1.x), use the DosBufReset() function. In 32-bit
OS/2 (version 2.0), use the DosResetBuffer() function.

The Windows NT operating system provides the WIN32 API
FlushFileBuffers(). The _commit() function included with the
Visual C++ 32-bit Edition CRT calls FlushFileBuffers to
write buffered data to disk.

Microsoft C/C++ version 7.0 introduces the "c" mode option
for the fopen() function. When an application opens a file
and specifies the "c" mode, the run-time library writes the
contents of the file buffer to disk when the application
calls the fflush() or _flushall() function. The "c" mode
option is a Microsoft extension and is not part of the ANSI
standard for fopen().

To change the default behavior of the fflush() and
_flushall() functions, link your application with the
COMMODE.OBJ file provided by the products listed at the
beginning of this article. COMMODE.OBJ changes the global
commit flag such that calling fflush() or _flushall()
commits the file buffer to disk. This flag tells fflush() to
call _commit() to flush the low- level file when the stream
is flushed and _commit() in turn calls _dos_commit() for the
MS-DOS level file. By default flushing a stream does not
flush the low-level and MS-DOS level files.

Is This Answer Correct ?    19 Yes 1 No

Post New Answer

More C Interview Questions

#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


Explain About fork()?

0 Answers   TISL,


Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

0 Answers  


A MobileNumber is a VIP number if it satisfy the following conditions. The operator should be Vodafone. Atleast one 0 (Zero) should be exist in mobile number. The number should not end with 8. The single digit sum of all the digits in the number should be equal to 9. For example if the number is 9876543210, the sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9. Write a method: private boolean isVIPMobileNumber(String mobileNum, String operator) mobileNum phone number operator mobile operator as bsnl, Vodafone

1 Answers  


What is the use of header files?

0 Answers  






how to display 2-D array elements in spiral

2 Answers  


what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā€œ%d\nā€,j); }

14 Answers   Oracle,


What is the benefit of using const for declaring constants?

0 Answers  


what are the various memory handling mechanisms in C ?

4 Answers   HP,


write a addition of two no. program with out using printf,scanf,puts .

4 Answers  


i need all types of question paper releted to "c" and other language.

0 Answers  


Differentiate between the expression “++a” and “a++”?

0 Answers  


Categories