Table of Contents
This guide covers function setbuf ()() in c with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
Declare Setbuf ()() Function in C
Below is the declaration for the setbuf () function in C:
void setbuf ( FILE * stream , char * buffer )
Parameters
Stream - This is the pointer to a FILE object that identifies the opened stream.
Buffer - This is the buffer that has been allocated. It should be at least BUFSIZ bytes in length, which is a macro constant to be used as the length of this array.
Returns the value
This function does not return any values.
For example
The following program C illustrates the usage of the setbuf () function in C:
#include int main () { char buf [ BUFSIZ ]; setbuf ( stdout , buf ); puts ( "Hoc C co ban tai QTM !!!" ); fflush ( stdout ); return ( 0 ); }
Compile and run the above program to produce the following results. Here the program sends output to STDOUT just before it exits, otherwise it continues to buffer output. You can also use the fflush () function to flush (delete or move to the periphery) to see the result.
According to Tutorialspoint
Previous lesson: The rewind () function in C
Next lesson: Function setvbuf () in C
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.