SlideShare a Scribd company logo
Ms. K. D. Patil, AP, SCOE,Kopargaon 1
External Storage Devices
Prepared By
Ms. K. D. Patil, AP
Department of Information Technology
Sanjivani College of Engineering, Kopargaon
Ms. K. D. Patil, AP, SCOE,Kopargaon 2
Storage Devices
● A storage device is used in the computers to store the data.
● The media for storing the information in a computer is
usually divided into main two types
● Primary Memory
● Secondary Memory/Auxiliary Memory
● Provides one of the core functions of the modern
computer.
● The amount of data stored is measured in kilobytes (KB).
Ms. K. D. Patil, AP, SCOE,Kopargaon 3
Primary Storage
● Also known as main memory.
● Main memory is directly or indirectly connected to the central processing unit via a
memory bus.
● The CPU continuously reads instructions stored there and executes them as
required.
● It is characterized by having faster access, costing more per bits and having
smaller capacity.
● Usually uses semiconductor Technology. A semiconductor chip is a very large
scale integrated (VLSI) of transitors and other electronic computers.
● Example:
– RAM
– ROM
– Cache
Ms. K. D. Patil, AP, SCOE,Kopargaon 4
RAM
● It is called Random Access Memory because any of the data in RAM can be
accessed just as fast as any of the other data.
● Computers store temporary data in the RAM. These could be operating
instructions, loose bits of data or content from programs that are running.
● The contents of RAM are constantly rewritten as the data is processed.
● When the computer is switched off, all the data is cleared from the RAM.
● This type of memory is called volatile (Chage rapidly) because it only stores the
data while the computer is switched on.
● RAM sticks are found on the motherboard.
● There are two types of RAM:
– DRAM (Dynamic Random Access Memory)
– SRAM (Static Random Access Memory)
Ms. K. D. Patil, AP, SCOE,Kopargaon 5
RAM
● Static RAM
– Faster
– More expensive
– More power consumption
– does not need to be refreshed
● Dynamic RAM
– Slower
– Less expensive
– Less power consumption
– needs to be refreshed thousands of times per second
Ms. K. D. Patil, AP, SCOE,Kopargaon 6
ROM
● When a computer is first switched on, it needs to load up the BIOS
(Basic Input/Output System) and basic instructions for the
hardware.
● These are stored in ROM (Read Only Memory).
● This type of memory is calleThisd non-volatile (Can’t change
rapidly) because it retains the data.
● Data stored in ROM remains there even when the computer is
switched off.
● ROM can be found on the motherboard.
● ROM memory cannot be easily or quickly overwritten or modified .
Ms. K. D. Patil, AP, SCOE,Kopargaon 7
Cache
● Cache is a high-speed access area that can be
either a reserved section of main memory or a
storage device.
● Most computers today come with L3 cache or
L2 cache, while older computers included only
L1 cache.
Ms. K. D. Patil, AP, SCOE,Kopargaon 8
Secondary Storage/External
Storage Devices
● It is not directly accessible by the CPU.
● Computer usually uses its input/output channels
access secondary storage and transfers the desired
data using intermediate area in primary storage.
● Cost is less, storage capacity is more but access
time is also more.
● Example:
– Hard disk
Ms. K. D. Patil, AP, SCOE,Kopargaon 9
Types
● There are three main types of storage device:
● Those that store data by magnetizing a special material that coats the
surface of a disk.
Eg. magnetic tape, floppy disk, external hard disk drives
● Those that store data using optical technology to etch the data onto
a plastic-coated metal disk. Laser beams are then passed over the
surface to read the data.
Eg. CD, DVD, Blue-ray, M-Disc
● Flash drives use solid state technology and store data in a similar
way to the BIOS chip.
Eg. Memory card, Memory stick, USB drives
Ms. K. D. Patil, AP, SCOE,Kopargaon 10
Hard Disk
● The hard disk drive is the main, and usually largest,
data storage device in a computer.
● It can store anywhere from 160 gigabytes to 2
terabytes.
● Hard disk speed is the speed at which content can
be read and written on a hard disk.
● A hard disk unit comes with a set rotation speed
varying from 4500 to 7200 rpm.
● Disk access time is measured in milliseconds.
Ms. K. D. Patil, AP, SCOE,Kopargaon 11
Floppy Disk
● Floppy disks used to be used a lot, but they are unreliable and
don’t hold very much data, so they are rarely used now.
● They hold 1.44 MB of data, so are only really useful for backing
up or moving small files that don’t contain graphics.
● They are easily damaged, which means that files stored on
them won’t always load.
● As flash memory has become cheaper, many new computers
don’t even have a floppy disk drive
Ms. K. D. Patil, AP, SCOE,Kopargaon 12
Magnetic Tape
● A magnetically coated strip of plastic
on which data can be encoded.
● Tapes for computers are similar to
tapes used to store music.
● Tape is much less expensive than other storage
mediums but commonly a much slower solution
that is commonly used for backup.
Ms. K. D. Patil, AP, SCOE,Kopargaon 13
Optical Disc
● Optical disc is any storage media that holds content
in digital format and is read using a laser assembly
is considered optical media.
● The most common types of optical media are
– Blu-ray (BD)
– Compact Disc (CD)
– Digital Versatile Disc (DVD)
Ms. K. D. Patil, AP, SCOE,Kopargaon 14
CDs and DVDs
● CD and DVD look exactly the same, but DVDs hold much more
data than CDs and need different drives to read them.
● CD-ROMs are read only – you can read data from them but
can’t write more data to them.
● CD-Rs allow you to write data once, but you can’t write over it.
● CD-RWs allow you to write data and then record new data over
it.
● DVD-Rs and RWs follow the same pattern.
● You need special software to write to CDs and DVDs – you
cannot simply copy files to them.
Ms. K. D. Patil, AP, SCOE,Kopargaon 15
Comparison
CD DVD BD
Capacity 700MB 4.7GB - 17GB 50GB
Wavelength 780nm 650nm 405nm
Read/Write
Speed
1200KB/s 10.5MB/s 36MB/s
Example CD-ROM,
CD-R
CD-RW
DVD-ROM
DVD+R/RW
DVD-R/RW
DVD-RAM
BD-R
BD-RE
Ms. K. D. Patil, AP, SCOE,Kopargaon 16
Flash Drives
● In recent years, flash memory has become much more popular.
● It holds a lot of data in a very small space. Flash drives are available in sizes such as
256MB, 512MB, 1GB, 5GB, and 16GB and are an easy way to transfer and store
information.
● It doesn’t need special software to use it.
● Most computers will recognize the device as soon as you plug it in.
●
Flash memory sticks connect through USB or FireWire ports.
● Many other devices, like digital cameras and MP3 players, also use flash memory.
● Flash memory cards can hold different types of data so your MP3 player could hold a data
file with your homework on it, for example.
● A small, portable flash memory card that plugs into a computer’s USB port and functions as
a portable hard drive.
●
Memory cards are usually read by connecting the device containing the card to your
computer, or by using a USB card reader.
Ms. K. D. Patil, AP, SCOE,Kopargaon 17
File
● A file is a collection of records.
● large collections of information stored on devices outside the
computer's internal memory.
● It usually implies that the records are stored in secondary
storage in the computer's external memory, on tapes or disks.
● As a result, the ways in which the file must be organized so that
operations on it can be carried out efficiently are dependent on
the characteristics of the secondary storage devices used to
implement the file.
● The basic operations on a file are to insert and delete records,
process or update records, and search for or retrieve records.
Ms. K. D. Patil, AP, SCOE,Kopargaon 18
File
● Each file is a sequence of records.
● The data is subdivided into records (e.g., student
information).
● Each record is a sequence of fields. (e.g., name,
GPA).
● One (or more) field is the key field (e.g.,name).
● All files are assigned a name that is used for
identification purposes by the operating system and
the user.
Ms. K. D. Patil, AP, SCOE,Kopargaon 19
Types of File
● A file stored on a storage device is a sequence of bits that can
be interpreted by an application program as a text file or a
binary file file or a binary file.
● Text Files
– A text file is a file of plain text.
– To store these data types, they must be converted to their character
equivalent formats.
– Some files can only use character data types. Most notable are file
streams (input/output objects in some object-oriented language like
C++) for keyboards, monitors and printers.
– This is why we need special functions to format data that is
input from or output to these devices
Ms. K. D. Patil, AP, SCOE,Kopargaon 20
Types of File
● Binary Files
– A binary file is a collection of data stored in
the internal format of the computer.
– Unlike text files, binary files contain data that is
meaningful only if it is properly interpreted by a
program. If the data is textual, one byte is used to
represent one character (in ASCII encoding). But if
the data is numeric, two or more bytes are
considered a data item.
Ms. K. D. Patil, AP, SCOE,Kopargaon 21
File Operations
● Using a file in a program is a simple three-step
process
● The file must be opened. If the file does not yet
exits, opening it means creating it.
● Information is then saved to the file, read from
the file, or both.
● When the program is finished using the file, the
file must be closed.
Ms. K. D. Patil, AP, SCOE,Kopargaon 22
File Operations
Ms. K. D. Patil, AP, SCOE,Kopargaon 23
File Operations
Ms. K. D. Patil, AP, SCOE,Kopargaon 24
Opening a File
● File access requires the inclusion of fstream.h
● Before data can be written to or read from a file,
the file must be opened.
ifstream inputFile;
inputFile.open(“customer.txt”);
Ms. K. D. Patil, AP, SCOE,Kopargaon 25
Default Open Mode
File Type Default Open Mode
ofstream The file is opened for output only. (Information may
be written to the file, but not read from the file.) If
the file does not exist, it is created. If the file
already exists, its contents are deleted (the file is
truncated).
ifstream The file is opened for input only. (Information may
be read from the file, but not written to it.) The
file’s contents will be read from its beginning. If the
file does not exist, the open function fails.
Ms. K. D. Patil, AP, SCOE,Kopargaon 26
File Mode Flag
File Mode Flag Meaning
ios::app
Append mode. If the file already exists, its
contents are preserved and all output is written to
the end of the file. By default, this flag causes the
file to be created if it does not exist.
ios::ate
If the file already exists, the program goes directly
to the end of it. Output may be written anywhere
in the file.
ios::binary
Binary mode. When a file is opened in binary
mode, information is written to or read from it in
pure binary format. (The default mode is text.)
ios::in
Input mode. Information will be read from the file.
If the file does not exist, it will not be created and
the open function will fail.
Ms. K. D. Patil, AP, SCOE,Kopargaon 27
File Mode Flag
File Mode Flag Meaning
ios::nocreate
If the file does not already exist, this flag will
cause the open function to fail. (The file will
not be created.)
ios::noreplace
If the file already exists, this flag will cause
the open function to fail. (The existing file will
not be opened.)
ios::out
Output mode. Information will be written to
the file. By default, the file’s contents will be
deleted if it already exists.
ios::trunc
If the file already exists, its contents will be
deleted (truncated). This is the default mode
used by ios::out.
Ms. K. D. Patil, AP, SCOE,Kopargaon 28
Opening a File and Closing File
●Opening File
fstream dataFile(“names.dat”, ios::in | ios::out);
●Closing File
fstream dataFile;
dataFile.close();
Ms. K. D. Patil, AP, SCOE,Kopargaon 29
Testing for Open Errors
dataFile.open(“cust.dat”, ios::in);
if (!dataFile)
{
cout << “Error opening file.n”;
}
OR
dataFile.open(“cust.dat”, ios::in);
if (dataFile.fail())
{
cout << “Error opening file.n”;
}
Ms. K. D. Patil, AP, SCOE,Kopargaon 30
Detecting the End of a File
● The eof() member function reports when the
end of a file has been encountered.
if (inFile.eof())
inFile.close();
● The eof() function returns true
when there is no more information
to be read.
Ms. K. D. Patil, AP, SCOE,Kopargaon 31
Reading from the file & Writing to
the File
●
Read operation
fstream fin;
fin.read( (char *) &rec, sizeof(student) );
● The read() function takes two arguments.
● &rec : Initial byte of an object stored in file.
● sizeof(student) : size of object represents the total number of bytes to be read from initial byte.
●
Write operation
fstream fout;
fout.write( (char *) &rec, sizeof(student));
● The write() function takes two arguments.
● &rec : Initial byte of an object stored in memory.
● sizeof(student) : size of object represents the total number of bytes to be written from initial
byte.

More Related Content

What's hot

Virtual machine
Virtual machineVirtual machine
Virtual machine
Nikunj Dhameliya
 
Computer Organization
Computer OrganizationComputer Organization
Computer Organization
SOMASUNDARAM T
 
Raid and its levels
Raid and its levelsRaid and its levels
Raid and its levels
IGZ Software house
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory system
Mazin Alwaaly
 
Memory bits and bytes
Memory bits and bytesMemory bits and bytes
Memory bits and bytes
mac_see
 
Computer security
Computer securityComputer security
Computer security
EktaVaswani2
 
3. CPU virtualization and scheduling
3. CPU virtualization and scheduling3. CPU virtualization and scheduling
3. CPU virtualization and scheduling
Hwanju Kim
 
Memory Virtualization In Cloud Computing.pdf
Memory Virtualization In Cloud Computing.pdfMemory Virtualization In Cloud Computing.pdf
Memory Virtualization In Cloud Computing.pdf
Host It Smart
 
Web application
Web applicationWeb application
Web application
maliksiddique1
 
Presentation On RAID(Redundant Array Of Independent Disks) Basics
Presentation On RAID(Redundant Array Of Independent Disks) BasicsPresentation On RAID(Redundant Array Of Independent Disks) Basics
Presentation On RAID(Redundant Array Of Independent Disks) BasicsKuber Chandra
 
Operating systems galvin-ch1
Operating systems galvin-ch1Operating systems galvin-ch1
Operating systems galvin-ch1
Bat-Ochir Gan-Ochir
 
Memory hierarchy
Memory hierarchyMemory hierarchy
Memory hierarchy
Abu-ul-Haris
 
Virtualization and cloud Computing
Virtualization and cloud ComputingVirtualization and cloud Computing
Virtualization and cloud Computing
Rishikese MR
 
Presentation on Computer Processor
Presentation on Computer ProcessorPresentation on Computer Processor
Presentation on Computer Processor
MoizAlSamad
 
Digital Storage
Digital StorageDigital Storage
Digital Storage
MiXvideos
 
Types of operating system
Types of operating systemTypes of operating system
Types of operating system
Mohammad Alam
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
GlobalLogic Ukraine
 
Open Source Cloud
Open Source CloudOpen Source Cloud
Open Source Cloud
Rajet Veshin
 

What's hot (20)

Virtual machine
Virtual machineVirtual machine
Virtual machine
 
Computer Organization
Computer OrganizationComputer Organization
Computer Organization
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Raid and its levels
Raid and its levelsRaid and its levels
Raid and its levels
 
Computer architecture memory system
Computer architecture memory systemComputer architecture memory system
Computer architecture memory system
 
Memory bits and bytes
Memory bits and bytesMemory bits and bytes
Memory bits and bytes
 
Computer security
Computer securityComputer security
Computer security
 
3. CPU virtualization and scheduling
3. CPU virtualization and scheduling3. CPU virtualization and scheduling
3. CPU virtualization and scheduling
 
Memory Virtualization In Cloud Computing.pdf
Memory Virtualization In Cloud Computing.pdfMemory Virtualization In Cloud Computing.pdf
Memory Virtualization In Cloud Computing.pdf
 
Web application
Web applicationWeb application
Web application
 
Memory virtualization
Memory virtualizationMemory virtualization
Memory virtualization
 
Presentation On RAID(Redundant Array Of Independent Disks) Basics
Presentation On RAID(Redundant Array Of Independent Disks) BasicsPresentation On RAID(Redundant Array Of Independent Disks) Basics
Presentation On RAID(Redundant Array Of Independent Disks) Basics
 
Operating systems galvin-ch1
Operating systems galvin-ch1Operating systems galvin-ch1
Operating systems galvin-ch1
 
Memory hierarchy
Memory hierarchyMemory hierarchy
Memory hierarchy
 
Virtualization and cloud Computing
Virtualization and cloud ComputingVirtualization and cloud Computing
Virtualization and cloud Computing
 
Presentation on Computer Processor
Presentation on Computer ProcessorPresentation on Computer Processor
Presentation on Computer Processor
 
Digital Storage
Digital StorageDigital Storage
Digital Storage
 
Types of operating system
Types of operating systemTypes of operating system
Types of operating system
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
 
Open Source Cloud
Open Source CloudOpen Source Cloud
Open Source Cloud
 

Similar to External storage devices and basics of file

computer storage
computer storagecomputer storage
computer storage
Dipankar Dutta
 
Memory and storage
Memory and storage Memory and storage
Memory and storage
Tapan Khilar
 
Unit 3 storage fundamentals
Unit 3 storage fundamentalsUnit 3 storage fundamentals
Unit 3 storage fundamentals
Raj vardhan
 
secondry storage ahsan warraich
secondry storage ahsan warraichsecondry storage ahsan warraich
secondry storage ahsan warraich
ahsaniftikhar19
 
Chapter04 storage devices
Chapter04 storage devicesChapter04 storage devices
Chapter04 storage devicesshidabahri810
 
Storage devices and media
Storage devices and mediaStorage devices and media
Storage devices and media
Anjan Mahanta
 
Computer Introduction-Lecture02
Computer Introduction-Lecture02Computer Introduction-Lecture02
Computer Introduction-Lecture02
Dr. Mazin Mohamed alkathiri
 
storage devices.pdf
storage devices.pdfstorage devices.pdf
storage devices.pdf
Fajar Iqbal
 
Computer storage MBA present.pptx
Computer storage MBA present.pptxComputer storage MBA present.pptx
Computer storage MBA present.pptx
fazilathshaikh1
 
Storege or memory devises
Storege or memory devisesStorege or memory devises
Storege or memory devisesdevaki123
 
Memory
MemoryMemory
Memory
Saleem Mahar
 
Storage devices
Storage devicesStorage devices
Storage devices
rabail asghar
 
Media Storage
Media StorageMedia Storage
Media Storage
NeilfieOrit2
 
Computer Memory
Computer MemoryComputer Memory
Computer Memory
PravinGhosekar
 
5 computer memory
5 computer memory5 computer memory
5 computer memory
BaliThorat1
 
Computer Memory
Computer MemoryComputer Memory
Computer Memory
Sweta Kumari Barnwal
 
Computer MEMORY
Computer MEMORYComputer MEMORY
Computer MEMORY
Swarnima Tiwari
 
unit 3 cyber security 19.4.22.pptx
unit 3 cyber security  19.4.22.pptxunit 3 cyber security  19.4.22.pptx
unit 3 cyber security 19.4.22.pptx
ssuserd5e356
 
Consumer electronics seminar
Consumer electronics seminarConsumer electronics seminar
Consumer electronics seminar
Sai Ram
 

Similar to External storage devices and basics of file (20)

Storing data
Storing dataStoring data
Storing data
 
computer storage
computer storagecomputer storage
computer storage
 
Memory and storage
Memory and storage Memory and storage
Memory and storage
 
Unit 3 storage fundamentals
Unit 3 storage fundamentalsUnit 3 storage fundamentals
Unit 3 storage fundamentals
 
secondry storage ahsan warraich
secondry storage ahsan warraichsecondry storage ahsan warraich
secondry storage ahsan warraich
 
Chapter04 storage devices
Chapter04 storage devicesChapter04 storage devices
Chapter04 storage devices
 
Storage devices and media
Storage devices and mediaStorage devices and media
Storage devices and media
 
Computer Introduction-Lecture02
Computer Introduction-Lecture02Computer Introduction-Lecture02
Computer Introduction-Lecture02
 
storage devices.pdf
storage devices.pdfstorage devices.pdf
storage devices.pdf
 
Computer storage MBA present.pptx
Computer storage MBA present.pptxComputer storage MBA present.pptx
Computer storage MBA present.pptx
 
Storege or memory devises
Storege or memory devisesStorege or memory devises
Storege or memory devises
 
Memory
MemoryMemory
Memory
 
Storage devices
Storage devicesStorage devices
Storage devices
 
Media Storage
Media StorageMedia Storage
Media Storage
 
Computer Memory
Computer MemoryComputer Memory
Computer Memory
 
5 computer memory
5 computer memory5 computer memory
5 computer memory
 
Computer Memory
Computer MemoryComputer Memory
Computer Memory
 
Computer MEMORY
Computer MEMORYComputer MEMORY
Computer MEMORY
 
unit 3 cyber security 19.4.22.pptx
unit 3 cyber security  19.4.22.pptxunit 3 cyber security  19.4.22.pptx
unit 3 cyber security 19.4.22.pptx
 
Consumer electronics seminar
Consumer electronics seminarConsumer electronics seminar
Consumer electronics seminar
 

More from KanchanPatil34

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
KanchanPatil34
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
KanchanPatil34
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
KanchanPatil34
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
KanchanPatil34
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
KanchanPatil34
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
KanchanPatil34
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
KanchanPatil34
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
KanchanPatil34
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
KanchanPatil34
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
KanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
KanchanPatil34
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
KanchanPatil34
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
KanchanPatil34
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
KanchanPatil34
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
KanchanPatil34
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
KanchanPatil34
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
KanchanPatil34
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idt
KanchanPatil34
 

More from KanchanPatil34 (20)

Unit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdfUnit 2_2 Binary Tree as ADT_General Tree.pdf
Unit 2_2 Binary Tree as ADT_General Tree.pdf
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
 
Unit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdfUnit 2_3 Binary Tree Traversals.pdf
Unit 2_3 Binary Tree Traversals.pdf
 
Unit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdfUnit 1_SLL and DLL.pdf
Unit 1_SLL and DLL.pdf
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
PAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 MicroporcessorPAI Unit 3 Paging in 80386 Microporcessor
PAI Unit 3 Paging in 80386 Microporcessor
 
PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386PAI Unit 3 Multitasking in 80386
PAI Unit 3 Multitasking in 80386
 
PAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessorPAI Unit 2 Segmentation in 80386 microprocessor
PAI Unit 2 Segmentation in 80386 microprocessor
 
PAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentationPAI Unit 2 Protection in 80386 segmentation
PAI Unit 2 Protection in 80386 segmentation
 
SE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentationSE PAI Unit 2_Data Structures in 80386 segmentation
SE PAI Unit 2_Data Structures in 80386 segmentation
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Timer Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
SE PAI Unit 5_Serial Port Programming in 8051 micro controller_Part 3
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 2
 
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
SE PAI Unit 5_Serial Port Programming in 8051 microcontroller_Part 1
 
SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051SE PAI Unit 5_IO programming in 8051
SE PAI Unit 5_IO programming in 8051
 
Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2Unit 5_Interrupt programming in 8051 micro controller - part 2
Unit 5_Interrupt programming in 8051 micro controller - part 2
 
Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1Unit 5_interrupt programming_Part 1
Unit 5_interrupt programming_Part 1
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
 
Unit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idtUnit 3 se pai_ivt and idt
Unit 3 se pai_ivt and idt
 

Recently uploaded

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

External storage devices and basics of file

  • 1. Ms. K. D. Patil, AP, SCOE,Kopargaon 1 External Storage Devices Prepared By Ms. K. D. Patil, AP Department of Information Technology Sanjivani College of Engineering, Kopargaon
  • 2. Ms. K. D. Patil, AP, SCOE,Kopargaon 2 Storage Devices ● A storage device is used in the computers to store the data. ● The media for storing the information in a computer is usually divided into main two types ● Primary Memory ● Secondary Memory/Auxiliary Memory ● Provides one of the core functions of the modern computer. ● The amount of data stored is measured in kilobytes (KB).
  • 3. Ms. K. D. Patil, AP, SCOE,Kopargaon 3 Primary Storage ● Also known as main memory. ● Main memory is directly or indirectly connected to the central processing unit via a memory bus. ● The CPU continuously reads instructions stored there and executes them as required. ● It is characterized by having faster access, costing more per bits and having smaller capacity. ● Usually uses semiconductor Technology. A semiconductor chip is a very large scale integrated (VLSI) of transitors and other electronic computers. ● Example: – RAM – ROM – Cache
  • 4. Ms. K. D. Patil, AP, SCOE,Kopargaon 4 RAM ● It is called Random Access Memory because any of the data in RAM can be accessed just as fast as any of the other data. ● Computers store temporary data in the RAM. These could be operating instructions, loose bits of data or content from programs that are running. ● The contents of RAM are constantly rewritten as the data is processed. ● When the computer is switched off, all the data is cleared from the RAM. ● This type of memory is called volatile (Chage rapidly) because it only stores the data while the computer is switched on. ● RAM sticks are found on the motherboard. ● There are two types of RAM: – DRAM (Dynamic Random Access Memory) – SRAM (Static Random Access Memory)
  • 5. Ms. K. D. Patil, AP, SCOE,Kopargaon 5 RAM ● Static RAM – Faster – More expensive – More power consumption – does not need to be refreshed ● Dynamic RAM – Slower – Less expensive – Less power consumption – needs to be refreshed thousands of times per second
  • 6. Ms. K. D. Patil, AP, SCOE,Kopargaon 6 ROM ● When a computer is first switched on, it needs to load up the BIOS (Basic Input/Output System) and basic instructions for the hardware. ● These are stored in ROM (Read Only Memory). ● This type of memory is calleThisd non-volatile (Can’t change rapidly) because it retains the data. ● Data stored in ROM remains there even when the computer is switched off. ● ROM can be found on the motherboard. ● ROM memory cannot be easily or quickly overwritten or modified .
  • 7. Ms. K. D. Patil, AP, SCOE,Kopargaon 7 Cache ● Cache is a high-speed access area that can be either a reserved section of main memory or a storage device. ● Most computers today come with L3 cache or L2 cache, while older computers included only L1 cache.
  • 8. Ms. K. D. Patil, AP, SCOE,Kopargaon 8 Secondary Storage/External Storage Devices ● It is not directly accessible by the CPU. ● Computer usually uses its input/output channels access secondary storage and transfers the desired data using intermediate area in primary storage. ● Cost is less, storage capacity is more but access time is also more. ● Example: – Hard disk
  • 9. Ms. K. D. Patil, AP, SCOE,Kopargaon 9 Types ● There are three main types of storage device: ● Those that store data by magnetizing a special material that coats the surface of a disk. Eg. magnetic tape, floppy disk, external hard disk drives ● Those that store data using optical technology to etch the data onto a plastic-coated metal disk. Laser beams are then passed over the surface to read the data. Eg. CD, DVD, Blue-ray, M-Disc ● Flash drives use solid state technology and store data in a similar way to the BIOS chip. Eg. Memory card, Memory stick, USB drives
  • 10. Ms. K. D. Patil, AP, SCOE,Kopargaon 10 Hard Disk ● The hard disk drive is the main, and usually largest, data storage device in a computer. ● It can store anywhere from 160 gigabytes to 2 terabytes. ● Hard disk speed is the speed at which content can be read and written on a hard disk. ● A hard disk unit comes with a set rotation speed varying from 4500 to 7200 rpm. ● Disk access time is measured in milliseconds.
  • 11. Ms. K. D. Patil, AP, SCOE,Kopargaon 11 Floppy Disk ● Floppy disks used to be used a lot, but they are unreliable and don’t hold very much data, so they are rarely used now. ● They hold 1.44 MB of data, so are only really useful for backing up or moving small files that don’t contain graphics. ● They are easily damaged, which means that files stored on them won’t always load. ● As flash memory has become cheaper, many new computers don’t even have a floppy disk drive
  • 12. Ms. K. D. Patil, AP, SCOE,Kopargaon 12 Magnetic Tape ● A magnetically coated strip of plastic on which data can be encoded. ● Tapes for computers are similar to tapes used to store music. ● Tape is much less expensive than other storage mediums but commonly a much slower solution that is commonly used for backup.
  • 13. Ms. K. D. Patil, AP, SCOE,Kopargaon 13 Optical Disc ● Optical disc is any storage media that holds content in digital format and is read using a laser assembly is considered optical media. ● The most common types of optical media are – Blu-ray (BD) – Compact Disc (CD) – Digital Versatile Disc (DVD)
  • 14. Ms. K. D. Patil, AP, SCOE,Kopargaon 14 CDs and DVDs ● CD and DVD look exactly the same, but DVDs hold much more data than CDs and need different drives to read them. ● CD-ROMs are read only – you can read data from them but can’t write more data to them. ● CD-Rs allow you to write data once, but you can’t write over it. ● CD-RWs allow you to write data and then record new data over it. ● DVD-Rs and RWs follow the same pattern. ● You need special software to write to CDs and DVDs – you cannot simply copy files to them.
  • 15. Ms. K. D. Patil, AP, SCOE,Kopargaon 15 Comparison CD DVD BD Capacity 700MB 4.7GB - 17GB 50GB Wavelength 780nm 650nm 405nm Read/Write Speed 1200KB/s 10.5MB/s 36MB/s Example CD-ROM, CD-R CD-RW DVD-ROM DVD+R/RW DVD-R/RW DVD-RAM BD-R BD-RE
  • 16. Ms. K. D. Patil, AP, SCOE,Kopargaon 16 Flash Drives ● In recent years, flash memory has become much more popular. ● It holds a lot of data in a very small space. Flash drives are available in sizes such as 256MB, 512MB, 1GB, 5GB, and 16GB and are an easy way to transfer and store information. ● It doesn’t need special software to use it. ● Most computers will recognize the device as soon as you plug it in. ● Flash memory sticks connect through USB or FireWire ports. ● Many other devices, like digital cameras and MP3 players, also use flash memory. ● Flash memory cards can hold different types of data so your MP3 player could hold a data file with your homework on it, for example. ● A small, portable flash memory card that plugs into a computer’s USB port and functions as a portable hard drive. ● Memory cards are usually read by connecting the device containing the card to your computer, or by using a USB card reader.
  • 17. Ms. K. D. Patil, AP, SCOE,Kopargaon 17 File ● A file is a collection of records. ● large collections of information stored on devices outside the computer's internal memory. ● It usually implies that the records are stored in secondary storage in the computer's external memory, on tapes or disks. ● As a result, the ways in which the file must be organized so that operations on it can be carried out efficiently are dependent on the characteristics of the secondary storage devices used to implement the file. ● The basic operations on a file are to insert and delete records, process or update records, and search for or retrieve records.
  • 18. Ms. K. D. Patil, AP, SCOE,Kopargaon 18 File ● Each file is a sequence of records. ● The data is subdivided into records (e.g., student information). ● Each record is a sequence of fields. (e.g., name, GPA). ● One (or more) field is the key field (e.g.,name). ● All files are assigned a name that is used for identification purposes by the operating system and the user.
  • 19. Ms. K. D. Patil, AP, SCOE,Kopargaon 19 Types of File ● A file stored on a storage device is a sequence of bits that can be interpreted by an application program as a text file or a binary file file or a binary file. ● Text Files – A text file is a file of plain text. – To store these data types, they must be converted to their character equivalent formats. – Some files can only use character data types. Most notable are file streams (input/output objects in some object-oriented language like C++) for keyboards, monitors and printers. – This is why we need special functions to format data that is input from or output to these devices
  • 20. Ms. K. D. Patil, AP, SCOE,Kopargaon 20 Types of File ● Binary Files – A binary file is a collection of data stored in the internal format of the computer. – Unlike text files, binary files contain data that is meaningful only if it is properly interpreted by a program. If the data is textual, one byte is used to represent one character (in ASCII encoding). But if the data is numeric, two or more bytes are considered a data item.
  • 21. Ms. K. D. Patil, AP, SCOE,Kopargaon 21 File Operations ● Using a file in a program is a simple three-step process ● The file must be opened. If the file does not yet exits, opening it means creating it. ● Information is then saved to the file, read from the file, or both. ● When the program is finished using the file, the file must be closed.
  • 22. Ms. K. D. Patil, AP, SCOE,Kopargaon 22 File Operations
  • 23. Ms. K. D. Patil, AP, SCOE,Kopargaon 23 File Operations
  • 24. Ms. K. D. Patil, AP, SCOE,Kopargaon 24 Opening a File ● File access requires the inclusion of fstream.h ● Before data can be written to or read from a file, the file must be opened. ifstream inputFile; inputFile.open(“customer.txt”);
  • 25. Ms. K. D. Patil, AP, SCOE,Kopargaon 25 Default Open Mode File Type Default Open Mode ofstream The file is opened for output only. (Information may be written to the file, but not read from the file.) If the file does not exist, it is created. If the file already exists, its contents are deleted (the file is truncated). ifstream The file is opened for input only. (Information may be read from the file, but not written to it.) The file’s contents will be read from its beginning. If the file does not exist, the open function fails.
  • 26. Ms. K. D. Patil, AP, SCOE,Kopargaon 26 File Mode Flag File Mode Flag Meaning ios::app Append mode. If the file already exists, its contents are preserved and all output is written to the end of the file. By default, this flag causes the file to be created if it does not exist. ios::ate If the file already exists, the program goes directly to the end of it. Output may be written anywhere in the file. ios::binary Binary mode. When a file is opened in binary mode, information is written to or read from it in pure binary format. (The default mode is text.) ios::in Input mode. Information will be read from the file. If the file does not exist, it will not be created and the open function will fail.
  • 27. Ms. K. D. Patil, AP, SCOE,Kopargaon 27 File Mode Flag File Mode Flag Meaning ios::nocreate If the file does not already exist, this flag will cause the open function to fail. (The file will not be created.) ios::noreplace If the file already exists, this flag will cause the open function to fail. (The existing file will not be opened.) ios::out Output mode. Information will be written to the file. By default, the file’s contents will be deleted if it already exists. ios::trunc If the file already exists, its contents will be deleted (truncated). This is the default mode used by ios::out.
  • 28. Ms. K. D. Patil, AP, SCOE,Kopargaon 28 Opening a File and Closing File ●Opening File fstream dataFile(“names.dat”, ios::in | ios::out); ●Closing File fstream dataFile; dataFile.close();
  • 29. Ms. K. D. Patil, AP, SCOE,Kopargaon 29 Testing for Open Errors dataFile.open(“cust.dat”, ios::in); if (!dataFile) { cout << “Error opening file.n”; } OR dataFile.open(“cust.dat”, ios::in); if (dataFile.fail()) { cout << “Error opening file.n”; }
  • 30. Ms. K. D. Patil, AP, SCOE,Kopargaon 30 Detecting the End of a File ● The eof() member function reports when the end of a file has been encountered. if (inFile.eof()) inFile.close(); ● The eof() function returns true when there is no more information to be read.
  • 31. Ms. K. D. Patil, AP, SCOE,Kopargaon 31 Reading from the file & Writing to the File ● Read operation fstream fin; fin.read( (char *) &rec, sizeof(student) ); ● The read() function takes two arguments. ● &rec : Initial byte of an object stored in file. ● sizeof(student) : size of object represents the total number of bytes to be read from initial byte. ● Write operation fstream fout; fout.write( (char *) &rec, sizeof(student)); ● The write() function takes two arguments. ● &rec : Initial byte of an object stored in memory. ● sizeof(student) : size of object represents the total number of bytes to be written from initial byte.