• No results found

Electronic Science C and C++ Programming 38. Working with Files

N/A
N/A
Protected

Academic year: 2022

Share "Electronic Science C and C++ Programming 38. Working with Files "

Copied!
21
0
0

Loading.... (view fulltext now)

Full text

(1)

Electronic Science C and C++ Programming 38. Working with Files

Module - 38 Working with Files

Table of Contents

1. Introduction 2. File Streams 3. File types

4. Operations on files

5. Reading a character to a file / Writing a character from a file 6. File Pointers and their manipulation

7. Reading and writing block of data 8. Reading and writing objects 9. Random Access files

10. Error Handling during file operations 11. Summary

(2)

2

Electronic Science C and C++ Programming 38. Working with Files

Learning outcome –

After studying this module, you will be able to:

1. Get familiar with File streams 2. Learn about File streams 3. Study about operations on files

4. Learn about Reading a character to a file / Writing a character from a file 5. Study about File Pointers and their manipulation

6. Learn about Reading and writing block of data 7. Study about Reading and writing objects 8. Learn about Random Access files

9. Get familiar with Error Handling during file operations 1. Introduction

The Files are a way to store data permanently in a storage device. The file handling mechanism in C++ offers a mechanism to store up the output of a program in a file and to read from a file that is available on the disk. The <iostream>header file only provides predefined objects such as cinandcoutto take input from console and to write the output to a console correspondingly. The header file <fstream> is the header file which gives data types or classes of type ifstream,ofstream, fstreamwhich can be used to read the contents from a file and to write the contents on to a file.

2. File Streams

In C++, all the input/output operations are performed with the help o f streams. In general, a stream is a series of bytes that flows from an input/output device to the program. In C++, the operations on files are carrying out in a similar manner as like that of console input/output operations. A file stream is an interface among the programs and files. The stream that provides the information to the program is referred to as input stream. The stream that obtains the information from the program is referred to as output stream. In general, the input stream tries to read the information from the file, whereas the output stream tries to writes the information to the file. In C++, it is possible to open a file by connecting it to a stream. The graphic representation of file input/output using streams is as follows:

Input stream

Extraction fro m Input stream

Output stream

Insertion into Output stream Input device

Output device

PROGRAM

(3)

Electronic Science C and C++ Programming 38. Working with Files

The file streams in C++ that are used for file hand ling operations are:

Class Description

fstreambase It offers the operations that are universal to file streams. It supplies as a base for fstream, ifstream and ofstream classes. It includes open() and close() functions.

filebuf It carry out the input and output operations with files. The main task of it is to set the file buffers to read and write. It also includes open() and close() as member functions.

ifstream It offers input operations. It holds open() function with the default input mode. It can access the member functions like get(), getline(), seekg(), tellg() and read().

ofstream It offers output operations. It holds open() function with the default output mode.

It can access the member functions like put(),seekp(), tellp() and write().

fstream It permits instantaneous input and output operations on filebuf. The input and output is carried by member functions of the base classes istream and ostream. It holds open() function with the default input mode.

Since, the above classes are defined in fstream.h or fstream, therefore, to use any of these classes, it is must to include the <fstream.h> or <fstream> statement in the program.

3. File types

In general, there are two types of files, they are Sequential Access files and Random Access files.

a) Sequential Access Files

It is must that these files must be accessed in the same order in which they were written. This process is similar to audio cassette tapes where it is must to do rewind or fast forward through the songs in sequence to get to a particular song. In order to access the data from a sequential file, it is must that the search should start from the beginning of the file and search can be done through the entire file for the data which is required.

b) Random Access Files

These types of files are similar to audio compressed disks, where it is possible to access any song, in spite of of the order in which the songs were recorded. The important feature of the random access files allows instantaneous access to any data in the file. But, the disadvantage is that, they occupy more disk space than sequential access files.

4. Ope rations on Files

Some of the operations that can be performed on files are Opening a file, Closing a file, Reading from a file, Writing to a file, Checking for End-Of-File condition etc.

4.1 Opening a file

(4)

4

Electronic Science C and C++ Programming 38. Working with Files

It is must that a file must be opened before the information is read from it or before the information is written onto it. The ofstream object or fstream object is to be used to open a file for writing, where as the ifstream object is to be used to open a file for reading.

Syntax:

void open(const char *filename, ios::openmode mode);

In the above syntax:

The first argument indicate the name and location of the file that is to be opened

The second argument of the open() member function identify the mode in which the file should be opened.

Some of the commonly used file opening modes are:

It is possible to join two or more of these value by O Ring them together.

Example:

ofstream ofs;

ofs.open("firstfile.dat", ios::out | ios::trunc );

fstream fs;

fs.open("testfile.txt", ios::out | ios::in );

4.2 Closing a File

When a C++ program ends, it involuntarily closes and flushes all the streams and release all the memory that is allocated and it also closes if any opened files are there.

Syntax:

void close();

Example:

fs.close();

ofs.close();

4.3 Writing to a File

To write the information to the file from the pro gram, it is must to use an ofstream or fstream object instead of the cout object. It is must to enter the file name with File Mode Functionality

ios::in Opens a file for reading ios::out Opens a file for writing

ios::app Appends the data to the end of the file

ios::ate The file pointer moves to the end of the file but it allows to writes data in any place in the file

ios::trunc If the file already exists, then its contents will be removed before opening the file.

(5)

Electronic Science C and C++ Programming 38. Working with Files

extension to open that file with the help of functionopen(). After opening the preferred file, it is must from the user to to enter some content to store in the file. In the end, it is must to close the file by using the functionclose().

Program to write the information to a file

#include<iostream>

#include<fstream>

#include<stdlib>

using namespace std;

int main() {

ofstream ofs;

char lineoftext[100], filename[20];

cout<<"Enter a file name with extension to create a file : ";

gets(filename);

ofs.open(filename);

if(!ofs) {

cout<<"Error in opening a file"<<endl;

exit(0);

}

cout<<"Enter the lines which is to be written to file"<<endl;

while(strlen(gets(lineoftext))>0) {

ofs<<lineoftext;

ofs<<"\n";

}

ofs.close();

}

When the above program is compiled and executed, it produces the following result:

Enter a file name with extension to create a file : line.txt It is first line of text

It is second line of text It is third line of text It is fourth line of text 4.4. Reading from a File

To read information from the file with the help of the c++ program, it is must to use an ifstream or fstream object instead of the cin object. It is must initially to ask the user to enter the file name with extension with the help of functionopen(). Once the file name is given by the user, it is must to read the file contents character by character and show its content character by character at the time of reading on the output screen.

Program to read the contents of the file

#include<iostream>

(6)

6

Electronic Science C and C++ Programming 38. Working with Files

#include<string>

#include<fstream>

#include<stdlib>

int main() {

ifstream ifs;

char lineoftext[100], filename[20];

cout<<"Enter file name to read and show the contents";

cin>>fname;

ifs.open(fname);

if(!ifs) {

cout<<"Error in opening file..!!";

exit(0);

}

while(ifs.eof()==0) {

ifs>>lineoftext;

cout<<lineoftext<<" ";

}

cout<<"\n";

ifs.close();

}

When the above program is compiled and executed, it produces the following result:

It is first line of text It is second line of text It is third line of text It is fourth line of text

4.5. Detecting End-Of-File

It is possible to detect when the end of the file is reached by using the member function eof().

Syntax:

int eof();

The special function, eof( ), returns nonzero, i.e., TRUE value when there is no more data to be read from an input file stream, otherwise, it returns zero, i.e., FALSE.

Example:

ifstream ifs ;

ifs.open("first", ios::in | ios::binary);

while(!ifs.eof()) {

…..

}

if(ifs.eof())

cout << "End of file is reached \n" ;

(7)

Electronic Science C and C++ Programming 38. Working with Files

Program which reads and writes the information onto the file

#include <fstream>

#include <iostream>

using namespace std;

int main () {

char text[100];

ofstream ofs;

ofs.open("first.txt");

cout << "Writing the information to the file" << endl;

cout << "Enter name: ";

cin.getline(text, 100);

ofs << data << endl;

cout << "Enter age: ";

cin >> text;

cin.ignore();

ofs << data << endl;

ofs.close();

ifstream ifs;

ifs.open("first.txt");

cout << "Reading the information from the file" << endl;

ifs >> text;

cout << text << endl;

ifs >> data;

cout << text << endl;

return 0;

}

When the above code is compiled and executed, it produces the following result:

Writing the information to the file Enter name: Xyz

Enter your age: 20

Reading the information from the file Xyz

20

5. Reading a characte r to a file / Writing a character from a file

The two different methods that are available to read and write characters from the file are:

 Using insertion and extraction operators on the stream object

 Using member functions get() and put()

5.1 Using insertion and extraction operators on the stream object

The insertion and extraction operators can be used not only with predefined objects cin and cout, but they can also be used with fstreams.

Example:

(8)

8

Electronic Science C and C++ Programming 38. Working with Files

To write a character "a" to a file stream named "ofs"

ofs<<’a’;

To read a character from a file stream "ifs"

char ch1;

ifs>>ch1;

5.2 Using me mber functions get() and put()

The stream classes have two member functions that can be used for input and output operations, they are get() and put().

5.2.1 get()

The member function get() is used to read a single character form the associated stream.

Syntax:

stream-object.get() Example:

file.get(ch);

5.2.2 put()

The member function put() is used to write a single character to the associated stream.

Syntax:

stream-object.put(character) Example:

file.put(ch);

Program to read characters from a file

#include <iostream>

#include <fstream>

using namespace std;

int main() {

ifstream ifs;

ifs.open("my_input_file.txt", ios::in);

char ch1;

int no_of_lines = 0;

while (!ifs.eof() )

{

ifs.get(ch1);

cout << ch1;

if (ch1 == '\n') {

++no_of_lines;

} }

(9)

Electronic Science C and C++ Programming 38. Working with Files

cout << "Number of lines in the file are : " << no_of_lines << endl;

return 0;

}

When the above code is compiled and executed, it produces the following result:

Welcome to First

c++

program

Number of lines in the file are 4

6. File Pointers and their manipulation

All the objects of i/o streams objects have at least one internal stream pointer. The ifstream, like istream, has a pointer which is known as the get pointer that points to the element to be read in the next input operation. The ofstream, like ostream, has a pointer which is known as the put pointer that points to the location where the next element that has to be written. The fstream, take over both, the get and the put pointers, from iostream, which itself is derived from both istream and ostream. The internal stream pointers that point to the reading or writing locations within a stream can be operated using the member functions, they are as follows : Function Description

seekg( ) Moves the get pointer to a particular location in the file seekp( ) Moves the put pointer to a particular location in the file tellg( ) Returns the position of get pointer

tellp( ) Returns the position of put pointer The other prototype for seekg() and seekp() functions is:

seekg(offset, refposition );

seekp(offset, refposition );

In the above syntax:

The parameter offset characterize the number of bytes the file pointer is to be moved from the location that is specified by the parameter refposition. The refposition can have any one of the three constants that are defined in the ios class, they are:

Constant Description ios::beg Start of the file ios::end End of the file

ios::cur Present position of the pointer Example:

file.seekg(-10, ios::cur);

Program to obtain the size of the .bin file

#include <iostream>

(10)

10

Electronic Science C and C++ Programming 38. Working with Files

#include <fstream>

using namespace std;

int main () {

streampos begin,end;

ifstream ifs ("test.bin", ios::binary);

begin = ifs.tellg();

ifs.seekg (0, ios::end);

end = ifs.tellg();

ifs.close();

cout << "size of the file is: " << (end-begin) << " bytes.\n";

return 0;

}

When the above program is compiled and executed, it produces the following result:

Size of the file is: 40 bytes

Program to implement the usage of tellp and seekp pointers

#include <fstream>

using namespace std;

int main () {

long pos;

ofstream ofs;

ofs.open ("contents.txt");

ofs.write ("My Name is Abcd",15);

pos=ofs.tellp();

ofs.seekp (pos-4);

ofs.write ("Riya",5);

ofs.close();

return 0;

}

When the above code is compiled and executed, it produces the following result:

My name is Riya

7. Reading and writing block of data

The functions that are used to read and write blocks of binary data are read() and write().

a) read() Syntax:

ifstream& read ( char* t, int n );

The read() function reads a block of data of n characters and stores it in the array that is pointed by t. If the End-of-File is reached before n characters have been read, then, the array will have all the elements read until it.

Example :

(11)

Electronic Science C and C++ Programming 38. Working with Files

To read 3 integers from a file named "numbers"

int num[3];

ifstream ifs("numbers");

ifs.read((char*)num,3*sizeof(int));

b) write() Syntax:

ofstream& write ( const char* t , int n );

The write() function writes the block of data that is pointed by t, with a size of n characters, into the output buffer. The characters are written in sequence until n have been written.

Example :

To read 4 floating point numbers to a file "fnumbers"

float fnum[3];

ofstream ofs(“fnumbers”);

ofs.write((char*)&fnum,3*sizeof(fnum));

Program to implement the usage of read() and write () functions on binary file handling

#include<iostream>

#include<fstream>

#include<stdlib>

using namespace std;

int main() {

fstream fs;

int num[10]={5,10,15,20,25,30,35,40,45,50};

fs.open("integers",ios::in|ios::out|ios::binary);

if(!fs) {

cout<<"error in opening file"<<endl;

exit(0);

}

fs.write((char*)num,sizeof(num));

fs.seekg(0);

int integers[5];

fs.read((char*)integers, 5*sizeof(int));

cout<<"The contents of the integers array are"<<endl;

for(int i=0; i<5; i++)

cout<<integers[i]<< " ";

fs.close();

return 0;

}

When the above program is compiled and executed, it produces the following result:

The contents of the integers array are 5 10 15 20 25

(12)

12

Electronic Science C and C++ Programming 38. Working with Files

8. Reading and writing objects

C++ programs mostly deals with classes and objects. It is possible to read and write class objects to binary files. When an object is written to a file, only, the data members are written to the file and the member functions are not written to the file.

The syntax to read an object using a file is as follows:

stream_object.read((char*) &object_name,size);

The syntax to write an object using a file is as follows:

stream_object.write((char*) &object_name,size);

Example:

To write an object named e1 of class employee to the file “emp”

emp e1(101,”aaa”);

ofstream ofs(“emp”);

ofs.write((char*)&e1, sizeof(e1));

To read a single object of type employee into object named e2 from file “emp”

emp e2;

ifstream ifs(“emp”);

ifs.read((char*)&e2, sizeof(e2));

Program to read and write and employee object to a file

#include<iostream>

#include<stdlib>

#include<fstream>

using namespace std;

class employee {

public:

int empno;

char empname[30];

void put();

void get();

void processing_details();

}; employee e;

void employee::put() {

fstream fs;

cout<<"\nEnter empno ";

cin>>empno;

cout<<"\nEnter employee name ";

(13)

Electronic Science C and C++ Programming 38. Working with Files

cin.getline(empname,30);

fs.open("employee.dat",ios::out|ios::app);

fs.write((char *)this,sizeof(employee));

fs.close();

e.processing_details();

}

void employee::get() {

int temp;

cout<<"\nEnter emp no ";

cin>>temp;

fstream fs;

fs.open("employee.dat",ios::in);

fs.seekg(0,ios::beg);

while(fs.read((char *)this,sizeof(employee))) {

if(empno==temp)

{

cout<<"\nemp no.: "<<empno<<endl;

cout<<"\nemployee name: "<<empname<<endl;

}

}

fs.close();

e.processing_details();

}

void employee:: processing_details () {

int ch;

cout<<"\nEnter the choice (1- input, 2-output, 3-exit) "<<endl;

cin>>ch;

switch(ch) {

case 1:

e.put();

break;

case 2:

e.get();

break;

case 3:

exit(0);

(14)

14

Electronic Science C and C++ Programming 38. Working with Files

default:

cout<<"\nwrong choice ";

} } int main() {

e.processing_details();

return 0;

}

When the above code is compiled and executed, it produces the following result:

Enter the choice (1-Input, 2-Output, 3-exit) 1

Enter emp no 1

Enter employee name: Deepali

Enter your choice (1-Input, 2-Output, 3-exit) 2

Enter emp no 1 Empno : 1

Employee name.: Deepali 9. Random Access files

In order to access the information in a sequential file, it is must to read from the beginning of the file, till the point where the requisite information is available. But, it is a time consuming process for large databases, because they contains huge amount of data. This problem can be avoided by using a new file type known as random access files, because, it is probable to access any information by omitting as many bytes as required, from the starting of the file. The number of bytes that is to be omitted to access any information is called as the offset. The two important functions that can be used to write data and read data in binary format are :

a) read()

The read() function is used to read the information from a random access file.

Syntax:

read((char*) &x,sizeof(x));

b) write()

The write() function is used to write the data in binary format.

Syntax:

write((char*) &x,sizeof(x));

In the above syntax:

x is the data to be written to the file.

The 1st argument to the function is a pointer to a character string The sizeof(x) is the number of bytes that is required for writing x.

(15)

Electronic Science C and C++ Programming 38. Working with Files

Program to demonstrate the concept of random access file handling

#include<fstream >

#include<stdlib >

#include<stdio>

#include<string>

class employee {

int empno;

char empname[20];

char department[3];

float salary;

public:

void accept() {

cout<<"\nEmpno: ";

cin>>empno;

cout<<"\nEmp Name: ";

cin>>empname;

cout<<"\nDepartment: ";

cin>>department;

cout<<"Salary: ";

cin>>salary;

}

void display() {

cout<<"\nEmpno: "<<empno<<"\tEmpName: "<<empname<<"\n";

cout<<"\nDepartment "<<department<<"\tSalary"<<salary<<"\n";

}

int getempno() {

return empno;

}

void modify();

}emp1, emp;

void employee::modify() {

cout<<"Empno: "<<empno<<"\n";

cout<<"EmpName: "<<empname<<"\tDepartment: "<<department<<"\tSalary: "

<<salary<<"\n";

(16)

16

Electronic Science C and C++ Programming 38. Working with Files

cout<<"Enter new details.\n";

char newname[20]=" ", newdept[3]=" ";

float newsalary;

cout<<"\nNew name:(Enter '.' to retain old one): ";

cin>>newname;

cout<<"\nNew department:(Press '.' to retain old one): \n";

cin>>newdept;

cout<<"\nNew salary:(Press -1 to retain old one): \n";

cin>>newsalary;

if(strcmp(newname, ".")!=0) {

strcpy(name, newname);

}

if(strcmp(newdept, ".")!=0) {

strcpy(department, newdepartment);

}

if(newsalary != -1) {

salary = newsalary;

} }

int main() {

fstream fs("employee.dat", ios::in | ios::out);

char ch='y';

while(ch=='y' || ch=='Y') {

emp1.accept();

ifs.write((char *)&emp1, sizeof(emp1));

cout<<"\nRecord is added to the file\n";

cout<<"\nWant to enter more ? (y/n).. ";

cin>>ch;

} int eno;

long position;

char flag='f';

cout<<"\nEnter empno of employee whose record is to be modified: ";

cin>>eno;

ifs.seekg(0);

(17)

Electronic Science C and C++ Programming 38. Working with Files

while(!ifs.eof()) {

position = ifs.tellg();

ifs.read((char *)&emp1, sizeof(emp1));

if(emp1.geteno() == eno) {

emp1.modify();

ifs.seekg(position);

ifs.write((char *)&emp1, sizeof(emp1));

flag = 't';

break;

} }

if(flag=='f') {

cout<<"\nEmployee Record does not exist..!!\n";

cout<<"Press any key to exit...\n";

exit(1);

}

ifs.seekg(0);

cout<<"\nThe contents of the file are: \n";

while(!ifs.eof()) {

ifs.read((char *)&emp, sizeof(emp));

emp.display();

}

ifs.close();

}

When the above code is compiled and executed, it produces the following result:

Empno: 101

Empname: Ajinkya Department: CS Salary: 25000

Record is added to the file Want to enter more ? (y/n).. y Empno: 102

Empname: Deepali Department:ELECT Salary: 20000

Record is added to the file Want to enter more ? (y/n).. n

Enter empno of employee whose record is to be modified: 101 Empno: 101

Empname: Ajinkya Department: CS Salary: 25000 Enter new details.

(18)

18

Electronic Science C and C++ Programming 38. Working with Files

New name:(Enter '.' to retain old one): Riya New department:(Press '.' to retain old one): PG New salary:(Press -1 to retain old one): 50000 The contents of the file are

Empno: 101 EmpName: Riya Department: ISS Salary: 50000 Empno: 102 EmpName: Deepali Department: ELECT Salary: 20000

10. Error Handling during file operations

C++ file streams come into 'stream-state' members from the ios class that store the information on the status of a file that is being currently used. There are a number of error handling functions that are carried by class ios that help to read and practice the group recorded in a file stream, they are:

Function Description

int bad() It returns a non-zero value (true value), if an unacceptable operation is attempted or any unrecoverable error has occurred. If it is zero (false value), it may be probable to improve from any other error reported and go on with operations.

int eof() It returns a non- zero (true value), if end-of-file is encountered while reading. Otherwise, it returns zero (false value).

int fail() It returns non- zero (true), when an input or output operation has failed.

int good() It returns non- zero (true), if no error has occurred. Otherwise, it returns zero (false value).

When it returns zero, there will be no additional operations that can be carried out.

clear() It reorganizes the error state, so that more operations can be attempted.

These functions may be used in the appropriate places in a program to find the status of a file stream.

Program to illustrate the use of error handling during file operations

#include<iostream >

#include<fstream>

#include<process>

#include<stdlib>

int main() {

char filename[20];

cout<<"\nEnter file name: ";

cin.getline(filename, 20);

ifstream ifs(filename, ios::in);

if(!ifs) {

(19)

Electronic Science C and C++ Programming 38. Working with Files

cout<<"\nError in opening the file\n";

cout<<"Press a key to exit...\n";

exit(1);

}

int value1, value2;

int result=0;

char operation;

ifs>>value1>>value2>>operation;

switch(operation) {

case '+':

result = value1 + value2;

cout<<"\n"<<value1<<" + "<<value2<<" = "<<result;

break;

case '-':

result = value1 - value2;

cout<<"\n"<<value1<<" - "<<value2<<" = "<<result;

break;

case '*':

result = value1 * value2;

cout<<"\n"<<value1<<" * "<<value2<<" = "<<result;

break;

case '/':

if(value2==0) {

cout<<"\nDivide by Zero Error..!!\n";

cout<<"\nPress any key to exit...\n";

exit(2);

}

result = value1 / value2;

cout<<"\n"<<value1<<" / "<<value2<<" = "<<result;

break;

}

ifs.close();

cout<<"\n\nPress any key to exit...\n";

}

When the above code is compiled and executed, it produces the following result:

Enter file name : myfile1.txt 10/5=2

Press any key to exit...

Enter file name : myfile2.txt Divide by Zero Error..!!

(20)

20

Electronic Science C and C++ Programming 38. Working with Files

Press any key to exit...

11. Summary

 In C++, all the input/output operations are performed with the help of streams.

 A file stream is an interface among the programs and files.

 The stream that provides the information to the program is referred to as input stream.

 The stream that obtains the information from the program is referred to as output stream.

 In C++, it is possible to open a file by connecting it to a stream.

 The fstream permits instantaneous input and output operations on filebuf.

 In order to access the data from a sequential file, it is must that the search should start from the beginning of the file and search can be done through the entire file for the data which is required.

 The important feature of the random access files allows instantaneous access to any data in the file.

 The ofstream object or fstream object is to be used to open a file for writing, where as the ifstream object is to be used to open a file for reading.

 The file pointer ios::ate moves to the end of the file but it allows to writes data in any place in the file.

 When a C++ program ends, it involuntarily closes and flushes all the streams and release all the memory that is allocated and it also closes if any opened files are there.

 To write the information to the file from the program, it is must to use an ofstreamorfstreamobject instead of thecoutobject.

 To read information from the file with the help of the c++ program, it is must to use anifstreamorfstreamobject instead of thecinobject.

 C++ provides a special function, eof( ), which returns nonzero, i.e., TRUE value when there is no more data to be read from an input file stream, otherwise, it returns zero, i.e., FALSE.

 The member function get() is used to read a single character form the associated stream.

 The member function put() is used to write a single character to the associated stream.

 The ifstream, like istream, has a pointer which is known as the get pointer that points to the element to be read in the next input operation.

 The seekp() moves the put pointer to a particular location in the file.

 The seekg() moves the get pointer to a particular location in the file.

 The tellg() returns the position of get pointer.

 The tellp() returns the position of put pointer.

 The parameter offset characterize the number of bytes the file pointer is to be moved from the location that is specified by the parameter refposition.

 The ios::cur present the position of the pointer.

(21)

Electronic Science C and C++ Programming 38. Working with Files

 The functions that are used to read and write blocks of binary data are read() and write().

 When an object is written to a file, only, the data members are written to the file and the member functions are not written to the file.

 The number of bytes that is to be omitted to access any information is called as the offset.

 The clear() reorganizes the error state, so that more operations can be attempted.

 The fail() returns non- zero (true), when an input or output operation has failed.

References

Related documents

• Link index blocks as in linked allocation. • Have

• “We need to be careful about what we wish for from a superhuman intelligence as we might get

g.t ; ½/ D .¾ C ½/e .¾ C ½/ t : (8) This means that the age distribution of an exponen- tially growing population of objects with (identical) exponential age distributions

Geo-BASE, is modeled using an Object-Relational approach and implemented with spatial data (vector data) stored as objects and the related non- spatial attribute data stored

The second edition of School Innovation Challenge 2021-22 organized in collaboration with the State Education Department, UNICEF India, Inqui-Lab Foundation,

17 / Equal to the task: financing water supply, sanitation and hygiene for a clean, the Ministry of Planning, Development and Special Initiatives is central to overall

Source: Ministry of Statistics and Programme Implementation; Reserve Bank of India; Annual reports of SOEs; Union Budget documents; Ministry of Corporate Affairs database;

While about thousand patents have been filed by the National Innovation Foundation, the vast majority of grassroots innovations and outstanding traditional knowledge practices