C Day-14
C Day-14
C Day-14
File modes
istream ostream
iostream
Detecting End-Of-File
It is necessary for preventing any attempt to read data from the
file.
Syntax : eof()
Syntax : cin.getline(char*,size);
write Function
It is used for displaying a text in a line until it encounters a ‘\n’
characters.
Syntax : cout.write(char*,size);
getline() and write() function Example
#include<iostream.h>
#include<conio.h>
void main()
{
char name[50];
clrscr();
Cout<<“Enetr any string”<<endl;
cin.getline(name,40);
cout.write(name,40);
getch();
}
Result
Enter any String : India is My Country
India is My Country
A stream is generally referred to a flow of data.
Each stream is associated with a particular class which contains
member functions and definitions for dealing with that particular
kind of data flow
The sequence of input bytes are called Input stream
The sequence of output bytes are called as output stream
The Ofstream is used for writing information to a file
The ifstream class is used for reading information from a file
The stream class is used for both writing and reading from a file