Page 297 - DCAP404 _Object Oriented Programming
P. 297

Object-oriented Programming




                    Notes                  cout  <<  “\nEmpl  Name:  “  <<  EmployeeName;
                                           cout  <<  “\nAddress:      “  <<  Address;
                                       cout << “\nCity:      “ << City;
                                          cout <<  “\nState:         “ <<  State;
                                           cout  <<  “\nZIP  Code:    “  <<  ZIPCode;
                                   */
                                           cout  <<  “\n\n”;

                                       return 0;
                                   }
                                   Closing an opened data file is the simplest of all the data file operations. All you have to do is to
                                   call the member function close() on the file stream hooked to the opened file. Once the file is
                                   closed it cannot be read/written unless reopened. The syntax for the same action is,
                                   File_stream_name.close();

                                   Self Assessment

                                   Fill in the blanks:
                                   13.  To perform file processing, you can declare an instance of an ………………….. object.

                                   14.  If you want to add things to an existing file then you must open it for appending by using
                                       …………………… when opening the file.

                                   13.6 Different Types of Files

                                   A file is a collection of letters, numbers and special characters: it may be a program, a database,
                                   a dissertation, a reading list, a simple letter etc.  Sometimes you may import a file from elsewhere,
                                   for example from another computer. If you want to enter your own text or data, you will start by
                                   creating a file. Whether you copied a file from elsewhere or created your own, you will need to
                                   return to it later in order to edit its contents.

                                   The most familiar file systems make use of an underlying data storage device that offers access
                                   to an array of fixed-size blocks,  sometimes called  sector, generally 512 bytes each. The  file
                                   system software is responsible for organizing these sectors into files and directories, and keeping
                                   track of which sectors belong to which file and which are not being used. Most file systems
                                   address data in fixed-sized units called “clusters” or “blocks” which contain a certain number of
                                   disk sectors (usually 1-64). This is the smallest logical amount of disk space that can be allocated
                                   to hold a file.
                                   However, file systems need not make use of a storage device at all. A file system can be used to
                                   organize and represent access to any data, whether it be stored or dynamically generated (e.g,
                                   from a network connection).
                                   Whether the file system has an underlying storage device or not, file systems typically have
                                   directories which associate file names with files, usually by connecting the file name to an index
                                   into a file allocation table of some sort, such as the FAT in an MS-DOS file system, or an inode in
                                   a Unix-like file system. Directory structures may be flat, or allow hierarchies where directories
                                   may contain subdirectories. In some file systems, file names are structured, with special syntax
                                   for  filename extensions  and version numbers. In  others, file  names are  simple strings, and
                                   per-file metadata is stored elsewhere.




          290                               LOVELY PROFESSIONAL UNIVERSITY
   292   293   294   295   296   297   298   299   300   301   302