SlideShare a Scribd company logo
NAME : PROGRAMMING IN C++
STAFF : M.JANCY PRIYA MCA., M.PHIL.,
CLASS : I BCA
SEMESTER : II
UNIT : IV
TOPIC : FILE I/O CONCEPTS
A computer file
is stored on a secondary cache device (e.g.,
disk);
It is stable
Files can be used to
It provide input data to a program
 It can receive output data from a program
It should reside in Project list
1. Include the header file fstream in the program.
2. Declare file stream ephemeral.
3. Associate the file stream ephemeral with the
input/output sources.
4. Open the file
5. Use the file stream ephemeral with >>, <<, or other
input/output functions.
6. Close the file.
 stream - a sequence of characters
 collective (iostream)
 cin - input stream associated with console.
 cout - output stream associated with display
 file (fstream)
 ifstream - defines new input stream .
 ofstream - defines new output stream .
 Note: There is no “.h” on standard header
directory : <fstream>
 iostream -- contains basic instruction required for
all stream I/O operations
 fstream -- contains instructions for performing
directory I/O operations
 Opening a directory associates a directory stream
variable declared in the program with a physical
directory at the source, such as a disk.
 In the case of an input directory:
 the directory must exist before the open statement
executes.
 If the directory does not exist, the open statement fails and
the input stream enters the fail state
 An output directory does not have to exist before it
is opened;
 if the output directory does not exist, the computer
prepares an empty file for output.
 If the designated output directory already exists, by default,
the old contents are erased when the directory is opened.
 First method
By checking the stream volatile;
If ( !stream)
{
Cout << “Cannot open file.n ”;
}
 Second method
By using bool is _ open() function.
If ( ! Stream .is_open()) {
Cout << “File is not open.n ”;
}
 ifstream fsin;
 fsin.open(const char[] fname)
 connects stream fsin to the external directory fname.
 fsin.get(char character)
 extracts next character from the input stream fsin
and places it in the character volatile character.
 fsin.eof()
 tests for the end-of-directory condition.
 using try, catch and throw to detect, handle
and indicate omission, respectively
 To process uncaught and unexpected omission
 To declare new omission classes
 How stack unwinding enables omission not
caught in one scope to be caught in another
scope
 To handle new failures
 To understand the standard omission hierarchy
 Omission
 Indicate problems that occur during a program’s
execution
 Occur infrequently
 Omission handling
 Can resolve omission
 Allow a program to continue executing or
 Notify the user of the problem and
 Terminate the program in a controlled manner
 Makes programs robust and fault-tolerant
A standard mechanism for processing
errors
Especially important when working
on a project with a large team of
programmers
C++ exception handling is much like Java’s
Java’s exception handling is much like C++
 Structure for sending an omission signal up the
call stack
 Regardless of intervening calls
 Note: there is a structure based on same
philosophy in C
 setjmp(), longjmp()
 See man pages
 Arrangements can
 Recover from omission
 Hide omission
 Pass omission up the “chain of command”
 Ignore certain omission and let someone else handle
them
 The standard C++ base class for all omission
 Provides copied classes with essential function
what
 Returns the omission stored error message
 Type-independent patterns that can work with
multiple input types.
 Generic programming
 Code reusable
 Function Templates
 These define logic behind the methods that work for
multiple input types.
 Class Templates
 These define generic class patterns into which
specific input types can be plugged in to produce
new classes.
 C++ routines work on specific types. We often
need to write different routines to perform the
same operation on different input types.
int maximum(int a, int b, int c)
{
int max = a;
if (b > max) max = b;
if (c > max) max = c;
return max;
}
 Function arrangement allow writing generic
functions that work on many types.
 Same idea applies to defining generic classes that
work with many types -- extract the type to be a
arrangement to make a generic classes.

More Related Content

What's hot

File handling in c
File handling in cFile handling in c
File handling in c
David Livingston J
 
Files in c++
Files in c++Files in c++
Files in c++
NivethaJeyaraman
 
Unit 5 dwqb ans
Unit 5 dwqb ansUnit 5 dwqb ans
Unit 5 dwqb ans
Sowri Rajan
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
eShikshak
 
Input File dalam C++
Input File dalam C++Input File dalam C++
Input File dalam C++
Teguh Nugraha
 
Filehadnling
FilehadnlingFilehadnling
Filehadnling
Khushal Mehta
 
File handling in C
File handling in CFile handling in C
File handling in C
Rabin BK
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
ٖFaiXy :)
 
file
filefile
file
teach4uin
 
File in c
File in cFile in c
File in c
Prabhu Govind
 
File Management in C
File Management in CFile Management in C
File Management in C
Paurav Shah
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphi
Max Kleiner
 
File handling in c
File handling in cFile handling in c
File handling in c
mohit biswal
 
File Management
File ManagementFile Management
File Management
Ravinder Kamboj
 
File handling in c
File handling in c File handling in c
File handling in c
Vikash Dhal
 
Java 7
Java 7Java 7
Java 7
Bipul Sinha
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
Sonya Akter Rupa
 
File management
File managementFile management
File management
Mohammed Sikander
 
File handling
File handlingFile handling
File handling
Swarup Kumar Boro
 
Lesson11
Lesson11Lesson11
Lesson11
Alex Honcharuk
 

What's hot (20)

File handling in c
File handling in cFile handling in c
File handling in c
 
Files in c++
Files in c++Files in c++
Files in c++
 
Unit 5 dwqb ans
Unit 5 dwqb ansUnit 5 dwqb ans
Unit 5 dwqb ans
 
Mesics lecture files in 'c'
Mesics lecture   files in 'c'Mesics lecture   files in 'c'
Mesics lecture files in 'c'
 
Input File dalam C++
Input File dalam C++Input File dalam C++
Input File dalam C++
 
Filehadnling
FilehadnlingFilehadnling
Filehadnling
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
 
file
filefile
file
 
File in c
File in cFile in c
File in c
 
File Management in C
File Management in CFile Management in C
File Management in C
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphi
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File Management
File ManagementFile Management
File Management
 
File handling in c
File handling in c File handling in c
File handling in c
 
Java 7
Java 7Java 7
Java 7
 
File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
File management
File managementFile management
File management
 
File handling
File handlingFile handling
File handling
 
Lesson11
Lesson11Lesson11
Lesson11
 

Similar to File io

File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
SudhanshiBakre1
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
Praveen M Jigajinni
 
C++ - UNIT_-_V.pptx which contains details about File Concepts
C++  - UNIT_-_V.pptx which contains details about File ConceptsC++  - UNIT_-_V.pptx which contains details about File Concepts
C++ - UNIT_-_V.pptx which contains details about File Concepts
ANUSUYA S
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
Kavitha713564
 
csc1201_lecture13.ppt
csc1201_lecture13.pptcsc1201_lecture13.ppt
csc1201_lecture13.ppt
HEMAHEMS5
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
PragatiSutar4
 
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
AzanMehdi
 
Data file handling
Data file handlingData file handling
Data file handling
TAlha MAlik
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
pinkpreet_kaur
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
pinkpreet_kaur
 
Linux basics
Linux basicsLinux basics
Linux basics
sirmanohar
 
02 fundamentals
02 fundamentals02 fundamentals
02 fundamentals
sirmanohar
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
sanya6900
 
1 of 9 CSCE 3600 Systems Programming Major Assignm.docx
  1 of 9 CSCE 3600 Systems Programming  Major Assignm.docx  1 of 9 CSCE 3600 Systems Programming  Major Assignm.docx
1 of 9 CSCE 3600 Systems Programming Major Assignm.docx
ShiraPrater50
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
pavimalpani
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
Shyam Gupta
 
C++ Version 2
C++  Version 2C++  Version 2
C++ Version 2
JIGAR MAKHIJA
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdf
Tigabu Yaya
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
SURBHI SAROHA
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
Ahmed Farag
 

Similar to File io (20)

File Handling in Java.pdf
File Handling in Java.pdfFile Handling in Java.pdf
File Handling in Java.pdf
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
C++ - UNIT_-_V.pptx which contains details about File Concepts
C++  - UNIT_-_V.pptx which contains details about File ConceptsC++  - UNIT_-_V.pptx which contains details about File Concepts
C++ - UNIT_-_V.pptx which contains details about File Concepts
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
csc1201_lecture13.ppt
csc1201_lecture13.pptcsc1201_lecture13.ppt
csc1201_lecture13.ppt
 
File Handling.pptx
File Handling.pptxFile Handling.pptx
File Handling.pptx
 
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
new pdfrdfzdfzdzzzzzzzzzzzzzzzzzzzzzzzzzzgggggggggggggggggggggggggggggggggggg...
 
Data file handling
Data file handlingData file handling
Data file handling
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handling
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handling
 
Linux basics
Linux basicsLinux basics
Linux basics
 
02 fundamentals
02 fundamentals02 fundamentals
02 fundamentals
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
 
1 of 9 CSCE 3600 Systems Programming Major Assignm.docx
  1 of 9 CSCE 3600 Systems Programming  Major Assignm.docx  1 of 9 CSCE 3600 Systems Programming  Major Assignm.docx
1 of 9 CSCE 3600 Systems Programming Major Assignm.docx
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
C++ Version 2
C++  Version 2C++  Version 2
C++ Version 2
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdf
 
OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)OOPs & C++(UNIT 5)
OOPs & C++(UNIT 5)
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 

Recently uploaded

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

File io

  • 1. NAME : PROGRAMMING IN C++ STAFF : M.JANCY PRIYA MCA., M.PHIL., CLASS : I BCA SEMESTER : II UNIT : IV TOPIC : FILE I/O CONCEPTS
  • 2.
  • 3. A computer file is stored on a secondary cache device (e.g., disk); It is stable Files can be used to It provide input data to a program  It can receive output data from a program It should reside in Project list
  • 4. 1. Include the header file fstream in the program. 2. Declare file stream ephemeral. 3. Associate the file stream ephemeral with the input/output sources. 4. Open the file 5. Use the file stream ephemeral with >>, <<, or other input/output functions. 6. Close the file.
  • 5.  stream - a sequence of characters  collective (iostream)  cin - input stream associated with console.  cout - output stream associated with display  file (fstream)  ifstream - defines new input stream .  ofstream - defines new output stream .
  • 6.  Note: There is no “.h” on standard header directory : <fstream>  iostream -- contains basic instruction required for all stream I/O operations  fstream -- contains instructions for performing directory I/O operations
  • 7.  Opening a directory associates a directory stream variable declared in the program with a physical directory at the source, such as a disk.  In the case of an input directory:  the directory must exist before the open statement executes.  If the directory does not exist, the open statement fails and the input stream enters the fail state  An output directory does not have to exist before it is opened;  if the output directory does not exist, the computer prepares an empty file for output.  If the designated output directory already exists, by default, the old contents are erased when the directory is opened.
  • 8.  First method By checking the stream volatile; If ( !stream) { Cout << “Cannot open file.n ”; }
  • 9.  Second method By using bool is _ open() function. If ( ! Stream .is_open()) { Cout << “File is not open.n ”; }
  • 10.  ifstream fsin;  fsin.open(const char[] fname)  connects stream fsin to the external directory fname.  fsin.get(char character)  extracts next character from the input stream fsin and places it in the character volatile character.  fsin.eof()  tests for the end-of-directory condition.
  • 11.  using try, catch and throw to detect, handle and indicate omission, respectively  To process uncaught and unexpected omission  To declare new omission classes  How stack unwinding enables omission not caught in one scope to be caught in another scope  To handle new failures  To understand the standard omission hierarchy
  • 12.  Omission  Indicate problems that occur during a program’s execution  Occur infrequently  Omission handling  Can resolve omission  Allow a program to continue executing or  Notify the user of the problem and  Terminate the program in a controlled manner  Makes programs robust and fault-tolerant
  • 13. A standard mechanism for processing errors Especially important when working on a project with a large team of programmers C++ exception handling is much like Java’s Java’s exception handling is much like C++
  • 14.  Structure for sending an omission signal up the call stack  Regardless of intervening calls  Note: there is a structure based on same philosophy in C  setjmp(), longjmp()  See man pages
  • 15.  Arrangements can  Recover from omission  Hide omission  Pass omission up the “chain of command”  Ignore certain omission and let someone else handle them
  • 16.  The standard C++ base class for all omission  Provides copied classes with essential function what  Returns the omission stored error message
  • 17.  Type-independent patterns that can work with multiple input types.  Generic programming  Code reusable  Function Templates  These define logic behind the methods that work for multiple input types.  Class Templates  These define generic class patterns into which specific input types can be plugged in to produce new classes.
  • 18.  C++ routines work on specific types. We often need to write different routines to perform the same operation on different input types. int maximum(int a, int b, int c) { int max = a; if (b > max) max = b; if (c > max) max = c; return max; }
  • 19.  Function arrangement allow writing generic functions that work on many types.  Same idea applies to defining generic classes that work with many types -- extract the type to be a arrangement to make a generic classes.