Streams and Files
View Code 1
View Code 2
Basic Concepts
- Stream
- a data type that processes characters
- Basically this is simple printing to the screen, input from the user,
and manipulating files.
- Each language has specific requirements so it is better to read up on
usage by yourself. Basic concepts are described here.
- Output
- sending out information
- I.e. printing to the screen.
- The default output device is the monitor.
- The main process of output is called Writing.
- Input
- receiving in information
- I.e. getting a value from the user.
- The default input device is the keyboard.
- The main process of output is called Reading.
- Looking at data but not reading it is called Peeking.
- Linear Processing
- the reading and/or writing to files in order of processing
- This is the basic way of processing streams. You process the
characters as they come.
- Random Access Processing
- the reading and/or writing to files in any order
- This is not as common as liner processing and not quite standard. It
is basically jumping around the stream. Think of a file rather than a
keyboard. Instead of typing words one after another, imagine moving a
cursor around a paragraph and typing words.
Files
- File
- a source of information
- These are used all the time. In general a three things are done in a
file:
- the file is opened
- the file is processed
- the file is close
- Try opening savable files from other programs (try .cfg) in a word
processor to see how they store data. Remember EDIT AT YOUR
OWN RISK!!!
- Text
- a file that only has characters, ends in .txt
- Data
- a file that only has numbers, ends in .dat
- ASCII File
- a file that holds both numbers and letters
- BOF
- acronym for Beginning Of File
- EOF
- acronym for End Of File, more commonly used than BOF
- Fail
- a common term for when something went wrong in writing or reading a file
Prev --
Back to Portal --
Next