Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes

C++ Programming Code Examples

Learn C++ Language

fflush() Function in C++ Programming Language

fflush() Function in C++
Flush stream. The fflush() function in C++ flushes any buffered data to the respective device. Buffered data is the temporary or application specific data stored in the physical memory of the computer until a certain time. If the given stream was open for writing (or if it was open for updating and the last i/o operation was an output operation) any unwritten data in its output buffer is written to the file. If stream is a null pointer, all such streams are flushed. In all other cases, the behavior depends on the specific library implementation. In some implementations, flushing a stream open for reading causes its input buffer to be cleared (but this is not portable expected behavior). The stream remains open after this call. When a file is closed, either because of a call to fclose or because the program terminates, all the buffers associated with it are automatically flushed.
Syntax for fflush() Function in C++
#include <cstdio> int fflush ( FILE * stream );
Pointer to a FILE object that specifies a buffered stream. Function returns a zero value indicates success. If an error occurs, EOF is returned and the error indicator is set (see ferror).
/* For output streams (and for update streams on which the last operation was output), writes any unwritten data from the stream's buffer to the associated output device. For input streams (and for update streams on which the last operation was input), the behavior is undefined. If stream is a null pointer, all open output streams are flushed, including the ones manipulated within library packages or otherwise not directly accessible to the program. */ /* flushes the output buffer of the stream by fflush function code example. */ #include <stdio.h> #include <iostream> using namespace std; int main() { char mybuffer[800]; FILE * file; file = fopen ("demo.txt","r+"); fputs ("test",file); fflush (file); // flushing required fgets (mybuffer,800,file); cout << mybuffer << endl; fclose (file); return 0; }

"Addition(+)" of 2 vectors. "Subtraction(-)" of 2 vectors. "Multiplication" of vector with the scalar. "Cross" product of 2 vectors. Scalar(or dot) product of 2 vectors. Negative of vectors

C++ program, "using iteration", implements the list of elements removed from the stack in last in first out mode using a linked list. A linked list is an ordered set of data elements,

There are different "Preprocessor Directives" that perform different tasks. Lets categorize preprocessor directives. Inclusion directives: "#include": specifies the files to be included,