C++ PPT (1).pptx cs thzt ix used for educational purposes

18kavin2005 9 views 13 slides Feb 28, 2025
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

ppt


Slide Content

FILE HANDLING KAVIN D(23PC21) SUDARSHAN D(23PC37) EOF,PEEK,PUTBACK,FLUSH

EOF(END OF FILE) *The eof () function is used to check the end of the stream occurred or not. *The eof () returns 1(true) when the end of the file occurred otherwise 0(false). *It is mostly used with input stream object while reading data from file.

example

OUTPUT:

PEEK: *Returns the next character in the input sequence, without extracting it: The character is left as the next character to be extracted from the stream . *Return Value: It returns the ASCII value of the character if successful, or EOF (-1) if the end-of-file is reached. *No Parameters: Unlike some other input functions, peek() doesn't require any parameters. It operates solely based on the current state of the input stream.

EXAMPLE:

OUTPUT:

PUTBACK() You can return the last character read from a stream to that stream by using putback( ). Its prototype is istream.putback (char c); where c is the last character read.

EXAMPLE 1

EXAMPLE 2

FLUSh () When output is performed, data is not necessarily immediately written to the physical device linked to the stream. Instead, information is stored in an internal buffer until the buffer is full. Only then are the contents of that buffer written to disk. However, you can force the information to be physically written to disk before the buffer is full by calling flush( ).

EXAMPLE

THANK YOU
Tags