SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
Introduction to file organization:
◦ What? Why? How?
File organization challenge
History of File organization
Streams operations
Dr. Hussien M. Sharaf 2
Dr. Hussien M. Sharaf 3
File organization : is rearranging data
structures and its operations in order to
enhance performance of data reading and
writing from and to secondary storage media
(disks).
Dr. Hussien M. Sharaf 4
Data structures
RAM/Main memory
Operations for
accessing data
File structures File processing
Secondary memory
(Disks)
Dr. Hussien M. Sharaf 5
File structures: is organization of data
representation on secondary devices such as
disks.
File processing (Streams Operations): The
processing (treatment) of data on secondary
devices such as disks. It involves transferring
data between secondary devices and RAM.
This will be built based on your knowledge of
Data Structures.
The study of file
organization and
processing is needed in
order to retrieve data from
secondary storage into
RAM so that programs can
process them.
The retrieval process must
be as fast as possible.
Dr. Hussien M. Sharaf 6
1. Minimize number of trips to the disk in
order to get desired information.
2. Grouping related information so that we
are likely to get everything we need with
only one trip to the disk (e.g. name, address,
phone number, account balance).
Dr. Hussien M. Sharaf 7
Dr. Hussien M. Sharaf 8
Dr. Hussien M. Sharaf 9
Reading/writing data is slow (since
electronic and mechanical)
Dr. Hussien M. Sharaf 10
Dr. Hussien M. Sharaf 11
Dr. Hussien M. Sharaf 12
ofstream: Stream class to write on files
ifstream: Stream class to read from files
fstream: Stream class to both read and
write from/to files.
Dr. Hussien M. Sharaf 13
ios::in Open for input operations.
ios::out Open for output operations.
ios::binary Open in binary mode.
ios::ate
Set the initial position at the end of the file.
If this flag is not set to any value, the initial position is the
beginning of the file.
ios::app
All output operations are performed at the end of the file,
appending the content to the current content of the file. This
flag can only be used in streams open for output-only
operations.
ios::trunc
If the file opened for output operations already existed
before, its previous content is deleted and replaced by the
new one.
Dr. Hussien M. Sharaf 14
ofstream myfile;
myfile.open ("example.bin", ios::out |
ios::app | ios::binary);
Dr. Hussien M. Sharaf 15
class default mode parameter
ofstream ios::out
ifstream ios::in
fstream ios::in | ios::out
ofstream myfile ("example.bin", ios::out |
ios::app | ios::binary);
Dr. Hussien M. Sharaf 16
if (myfile.is_open())
myfile << "This is a line.n";
myfile.close();
Check that the stream is
opened.
Write data into stream.
Close the stream and
hence the modifications are
saved into the file.
tellg() and tellp()
These two member functions return an integer
representing the current position of the get stream
pointer (in the case of tellg) or the put stream pointer
(in the case of tellp).
seekg(count, offset) and seekp(offset, direction)
These functions allow programmers to change the
position of the get and put stream pointers.
ios::beg offset counted from the beginning of the stream
ios::cur offset counted from the current position of the stream pointer
ios::end offset counted from the end of the stream
Dr. Hussien M. Sharaf 18
What does this program do?
- Obtain the size of a file
Check Examples 2.1 and 2.2
Write a program that generates a random array of 12
integers and then write each element into a new line in a
file “ArrayElem.txt”.
Send the source code project (after zipping it) to my email:
n.abdelhameed@fci-cu.edu.eg
Follow instructions made in the last page. Make sure to
send your ID. Students who don’t send their IDs clearly
will loose marks.
Dr. Hussien M. Sharaf 19
Check Examples 2.1 and 2.2 using VS2008 or VS2010
Write a program that reads a given number of lines from
“ArrayElem.txt” and displays them into one line
separated by comma “,”.
Send the source code project (after zipping it) to my email:
n.abdelhameed@fci-cu.edu.eg
Follow instructions made in the last page. Make sure to
send your ID. Students who don’t send their IDs clearly
will loose marks.
Dr. Hussien M. Sharaf 20
Next week is the deadline.
No excuses.
Don’t wait until last day.
I can help you to the highest limit within the next
3 days.
Dr. Hussien M. Sharaf 21
1. Delete the “bin” and “obj” folders.
2. Compress the solution folder using
winrar.
3. Rename the compressed file as follows:
StudentName_ID_A1.rar
StudentName_ID_A2.rar
4. Email to: n.abdelhameed@fci-cu.edu.eg
with your ID in the subject.
Dr. Hussien M. Sharaf 22
Intro File Org Streams Ops

Más contenido relacionado

La actualidad más candente

FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSFILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSVenugopalavarma Raja
 
File Handling
File HandlingFile Handling
File HandlingWaqar Ali
 
python file handling
python file handlingpython file handling
python file handlingjhona2z
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15Vishal Dutt
 
File management in C++
File management in C++File management in C++
File management in C++apoorvaverma33
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams Ahmed Farag
 
Data recovery-software
Data recovery-softwareData recovery-software
Data recovery-softwareSonika Rawat
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++Vineeta Garg
 
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter Trees
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter TreesExpediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter Trees
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter TreesDavid Lillis
 
Python files / directories part16
Python files / directories  part16Python files / directories  part16
Python files / directories part16Vishal Dutt
 
Data file handling in python reading & writing methods
Data file handling in python reading & writing methodsData file handling in python reading & writing methods
Data file handling in python reading & writing methodskeeeerty
 
Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operationsTAlha MAlik
 

La actualidad más candente (20)

FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUSFILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
FILE HANDLING IN C++. +2 COMPUTER SCIENCE CBSE AND STATE SYLLABUS
 
File Handling
File HandlingFile Handling
File Handling
 
python file handling
python file handlingpython file handling
python file handling
 
Python files / directories part15
Python files / directories  part15Python files / directories  part15
Python files / directories part15
 
File management in C++
File management in C++File management in C++
File management in C++
 
File Pointers
File PointersFile Pointers
File Pointers
 
File operations
File operationsFile operations
File operations
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Data recovery-software
Data recovery-softwareData recovery-software
Data recovery-software
 
Data file handling in c++
Data file handling in c++Data file handling in c++
Data file handling in c++
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Filehandlinging cp2
Filehandlinging cp2Filehandlinging cp2
Filehandlinging cp2
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter Trees
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter TreesExpediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter Trees
Expediting MRSH-v2 Approximate Matching with Hierarchical Bloom Filter Trees
 
File structures
File structuresFile structures
File structures
 
Python files / directories part16
Python files / directories  part16Python files / directories  part16
Python files / directories part16
 
Data file handling in python reading & writing methods
Data file handling in python reading & writing methodsData file handling in python reading & writing methods
Data file handling in python reading & writing methods
 
Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9
 
Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operations
 
2CPP17 - File IO
2CPP17 - File IO2CPP17 - File IO
2CPP17 - File IO
 

Destacado

Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File OrganizationMISY
 
Disk structure & File Handling
Disk structure & File HandlingDisk structure & File Handling
Disk structure & File HandlingMomina Idrees
 
Gps file structure explained
Gps file structure explainedGps file structure explained
Gps file structure explainedJaap Oosterhoff
 
Discussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsDiscussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsSangwon Lee
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure ConceptsDileep Kodira
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organizationBishal Ghimire
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controllerNirbhay Singh
 
File organization and processing
File organization and processingFile organization and processing
File organization and processingburhan123456
 
Ch 1-final-file organization from korth
Ch 1-final-file organization from korthCh 1-final-file organization from korth
Ch 1-final-file organization from korthRupali Rana
 
Concept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnersConcept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnerswellingtonoboh
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniquesMeghlal Khan
 
File organization 1
File organization 1File organization 1
File organization 1Rupali Rana
 
FILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMSFILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMSAbhishek Dutta
 
File Organization
File OrganizationFile Organization
File OrganizationManyi Man
 
File Management Presentation
File Management PresentationFile Management Presentation
File Management PresentationSgtMasterGunz
 

Destacado (20)

Ie Storage, Multimedia And File Organization
Ie   Storage, Multimedia And File OrganizationIe   Storage, Multimedia And File Organization
Ie Storage, Multimedia And File Organization
 
Disk structure & File Handling
Disk structure & File HandlingDisk structure & File Handling
Disk structure & File Handling
 
Gps file structure explained
Gps file structure explainedGps file structure explained
Gps file structure explained
 
CS215 - Lec 9 indexing and reclaiming space in files
CS215 - Lec 9  indexing and reclaiming space in filesCS215 - Lec 9  indexing and reclaiming space in files
CS215 - Lec 9 indexing and reclaiming space in files
 
Discussion : File structure of Meteor Apps
Discussion : File structure of Meteor AppsDiscussion : File structure of Meteor Apps
Discussion : File structure of Meteor Apps
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organization
 
register file structure of PIC controller
register file structure of PIC controllerregister file structure of PIC controller
register file structure of PIC controller
 
File organization and processing
File organization and processingFile organization and processing
File organization and processing
 
Ch 1-final-file organization from korth
Ch 1-final-file organization from korthCh 1-final-file organization from korth
Ch 1-final-file organization from korth
 
Concept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learnersConcept of computer files for Grade 12 learners
Concept of computer files for Grade 12 learners
 
File organization techniques
File organization techniquesFile organization techniques
File organization techniques
 
Handling computer files
Handling computer filesHandling computer files
Handling computer files
 
File organization
File organizationFile organization
File organization
 
File handling
File handlingFile handling
File handling
 
File organisation
File organisationFile organisation
File organisation
 
File organization 1
File organization 1File organization 1
File organization 1
 
FILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMSFILE STRUCTURE IN DBMS
FILE STRUCTURE IN DBMS
 
File Organization
File OrganizationFile Organization
File Organization
 
File Management Presentation
File Management PresentationFile Management Presentation
File Management Presentation
 

Similar a Intro File Org Streams Ops

ExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfaquacare2008
 
chapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfchapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfstudy material
 
File handling in_c
File handling in_cFile handling in_c
File handling in_csanya6900
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingChereLemma2
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDipayan Sarkar
 
File handling in C++
File handling in C++File handling in C++
File handling in C++Hitesh Kumar
 
basics of file handling
basics of file handlingbasics of file handling
basics of file handlingpinkpreet_kaur
 
Basics of file handling
Basics of file handlingBasics of file handling
Basics of file handlingpinkpreet_kaur
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdfsulekha24
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++Shyam Gupta
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handlingRai University
 

Similar a Intro File Org Streams Ops (20)

ExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdfExplanationThe files into which we are writing the date area called.pdf
ExplanationThe files into which we are writing the date area called.pdf
 
Filesin c++
Filesin c++Filesin c++
Filesin c++
 
chapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdfchapter-12-data-file-handling.pdf
chapter-12-data-file-handling.pdf
 
File handling in_c
File handling in_cFile handling in_c
File handling in_c
 
Data file handling
Data file handlingData file handling
Data file handling
 
File Management and manipulation in C++ Programming
File Management and manipulation in C++ ProgrammingFile Management and manipulation in C++ Programming
File Management and manipulation in C++ Programming
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K Karun
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
File in cpp 2016
File in cpp 2016 File in cpp 2016
File in cpp 2016
 
File handling in C++
File handling in C++File handling in C++
File handling in C++
 
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
 
File handling4.pdf
File handling4.pdfFile handling4.pdf
File handling4.pdf
 
Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
 
Chapter4.pptx
Chapter4.pptxChapter4.pptx
Chapter4.pptx
 
File handling3.pdf
File handling3.pdfFile handling3.pdf
File handling3.pdf
 
7 Data File Handling
7 Data File Handling7 Data File Handling
7 Data File Handling
 
cpp-file-handling
cpp-file-handlingcpp-file-handling
cpp-file-handling
 
Cpp file-handling
Cpp file-handlingCpp file-handling
Cpp file-handling
 

Más de Arab Open University and Cairo University

Más de Arab Open University and Cairo University (20)

Infos2014
Infos2014Infos2014
Infos2014
 
File Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswerFile Organization & processing Mid term summer 2014 - modelanswer
File Organization & processing Mid term summer 2014 - modelanswer
 
Model answer of compilers june spring 2013
Model answer of compilers june spring 2013Model answer of compilers june spring 2013
Model answer of compilers june spring 2013
 
Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013Model answer of exam TC_spring 2013
Model answer of exam TC_spring 2013
 
Theory of computation Lec6
Theory of computation Lec6Theory of computation Lec6
Theory of computation Lec6
 
Lec4
Lec4Lec4
Lec4
 
Theory of computation Lec3 dfa
Theory of computation Lec3 dfaTheory of computation Lec3 dfa
Theory of computation Lec3 dfa
 
Theory of computation Lec2
Theory of computation Lec2Theory of computation Lec2
Theory of computation Lec2
 
Theory of computation Lec1
Theory of computation Lec1Theory of computation Lec1
Theory of computation Lec1
 
Theory of computation Lec7 pda
Theory of computation Lec7 pdaTheory of computation Lec7 pda
Theory of computation Lec7 pda
 
Setup python with eclipse
Setup python with eclipseSetup python with eclipse
Setup python with eclipse
 
Cs419 lec8 top-down parsing
Cs419 lec8    top-down parsingCs419 lec8    top-down parsing
Cs419 lec8 top-down parsing
 
Cs419 lec11 bottom-up parsing
Cs419 lec11   bottom-up parsingCs419 lec11   bottom-up parsing
Cs419 lec11 bottom-up parsing
 
Cs419 lec12 semantic analyzer
Cs419 lec12  semantic analyzerCs419 lec12  semantic analyzer
Cs419 lec12 semantic analyzer
 
Cs419 lec9 constructing parsing table ll1
Cs419 lec9   constructing parsing table ll1Cs419 lec9   constructing parsing table ll1
Cs419 lec9 constructing parsing table ll1
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
Cs419 lec7 cfg
Cs419 lec7   cfgCs419 lec7   cfg
Cs419 lec7 cfg
 
Cs419 lec6 lexical analysis using nfa
Cs419 lec6   lexical analysis using nfaCs419 lec6   lexical analysis using nfa
Cs419 lec6 lexical analysis using nfa
 
Cs419 lec5 lexical analysis using dfa
Cs419 lec5   lexical analysis using dfaCs419 lec5   lexical analysis using dfa
Cs419 lec5 lexical analysis using dfa
 
Cs419 lec4 lexical analysis using re
Cs419 lec4   lexical analysis using reCs419 lec4   lexical analysis using re
Cs419 lec4 lexical analysis using re
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Último (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 

Intro File Org Streams Ops

  • 1.
  • 2. Introduction to file organization: ◦ What? Why? How? File organization challenge History of File organization Streams operations Dr. Hussien M. Sharaf 2
  • 3. Dr. Hussien M. Sharaf 3 File organization : is rearranging data structures and its operations in order to enhance performance of data reading and writing from and to secondary storage media (disks).
  • 4. Dr. Hussien M. Sharaf 4 Data structures RAM/Main memory Operations for accessing data File structures File processing Secondary memory (Disks)
  • 5. Dr. Hussien M. Sharaf 5 File structures: is organization of data representation on secondary devices such as disks. File processing (Streams Operations): The processing (treatment) of data on secondary devices such as disks. It involves transferring data between secondary devices and RAM. This will be built based on your knowledge of Data Structures.
  • 6. The study of file organization and processing is needed in order to retrieve data from secondary storage into RAM so that programs can process them. The retrieval process must be as fast as possible. Dr. Hussien M. Sharaf 6
  • 7. 1. Minimize number of trips to the disk in order to get desired information. 2. Grouping related information so that we are likely to get everything we need with only one trip to the disk (e.g. name, address, phone number, account balance). Dr. Hussien M. Sharaf 7
  • 8. Dr. Hussien M. Sharaf 8
  • 9. Dr. Hussien M. Sharaf 9
  • 10. Reading/writing data is slow (since electronic and mechanical) Dr. Hussien M. Sharaf 10
  • 11. Dr. Hussien M. Sharaf 11
  • 12. Dr. Hussien M. Sharaf 12
  • 13. ofstream: Stream class to write on files ifstream: Stream class to read from files fstream: Stream class to both read and write from/to files. Dr. Hussien M. Sharaf 13
  • 14. ios::in Open for input operations. ios::out Open for output operations. ios::binary Open in binary mode. ios::ate Set the initial position at the end of the file. If this flag is not set to any value, the initial position is the beginning of the file. ios::app All output operations are performed at the end of the file, appending the content to the current content of the file. This flag can only be used in streams open for output-only operations. ios::trunc If the file opened for output operations already existed before, its previous content is deleted and replaced by the new one. Dr. Hussien M. Sharaf 14
  • 15. ofstream myfile; myfile.open ("example.bin", ios::out | ios::app | ios::binary); Dr. Hussien M. Sharaf 15 class default mode parameter ofstream ios::out ifstream ios::in fstream ios::in | ios::out ofstream myfile ("example.bin", ios::out | ios::app | ios::binary);
  • 16. Dr. Hussien M. Sharaf 16 if (myfile.is_open()) myfile << "This is a line.n"; myfile.close(); Check that the stream is opened. Write data into stream. Close the stream and hence the modifications are saved into the file.
  • 17. tellg() and tellp() These two member functions return an integer representing the current position of the get stream pointer (in the case of tellg) or the put stream pointer (in the case of tellp). seekg(count, offset) and seekp(offset, direction) These functions allow programmers to change the position of the get and put stream pointers. ios::beg offset counted from the beginning of the stream ios::cur offset counted from the current position of the stream pointer ios::end offset counted from the end of the stream
  • 18. Dr. Hussien M. Sharaf 18 What does this program do? - Obtain the size of a file
  • 19. Check Examples 2.1 and 2.2 Write a program that generates a random array of 12 integers and then write each element into a new line in a file “ArrayElem.txt”. Send the source code project (after zipping it) to my email: n.abdelhameed@fci-cu.edu.eg Follow instructions made in the last page. Make sure to send your ID. Students who don’t send their IDs clearly will loose marks. Dr. Hussien M. Sharaf 19
  • 20. Check Examples 2.1 and 2.2 using VS2008 or VS2010 Write a program that reads a given number of lines from “ArrayElem.txt” and displays them into one line separated by comma “,”. Send the source code project (after zipping it) to my email: n.abdelhameed@fci-cu.edu.eg Follow instructions made in the last page. Make sure to send your ID. Students who don’t send their IDs clearly will loose marks. Dr. Hussien M. Sharaf 20
  • 21. Next week is the deadline. No excuses. Don’t wait until last day. I can help you to the highest limit within the next 3 days. Dr. Hussien M. Sharaf 21
  • 22. 1. Delete the “bin” and “obj” folders. 2. Compress the solution folder using winrar. 3. Rename the compressed file as follows: StudentName_ID_A1.rar StudentName_ID_A2.rar 4. Email to: n.abdelhameed@fci-cu.edu.eg with your ID in the subject. Dr. Hussien M. Sharaf 22