Class 12 Computer Science Chapter 14 Notes
Important Notes of full Class 12 Computer Science Chapter 14 Notes written by Professor Mr. Faraz Qasir Suib. These notes are very helpful in the preparation of Class 12 Computer Science Chapter 14 Notes of for the students of the intermediate and these are according to the paper patterns of all Punjab boards.
Summary and Contents:
Topics which are discussed in the notes are given below:
- Important Class 12 Computer Science Chapter 14 Notes for Intermediate part-II students.
- Define permanent storage / file: Answer :
Permanent Storage / File : When we write programs to work with temporary data,
the user has to enter data each time the program is executed. The data is stored on
permanent storage in the form of files. [A file is a set of related records stored on a
permanent storage medium].
- Explain The Concept of Streams in C.
- Explain New Line and EOF Marker in C: Answer :
NewLine and EOF Marker : A text file is a named collection of characters saved in
secondary storage e.g. on a disk. A text file has no fixed size. To mark the end of a
text file, a special end-of-file character is placed after the last character in the file
(denoted by EOF in C having ASCII Value 255 or xFF or all bits of the byte are 1s).
When we create a text file using a text editor such as notepad, pressing the ENTER
109
key causes a newline character (denoted by \n in C) to be placed at the end of each
line, and an EOF marker is placed at the end of the file. A specimen text file layout
(Organization of text in a text file .txt) on storage is :
- Explain File Opening in C, its Modes, and File Pointer
with an example program.
- Explain File Closing in C: Answer :
File Closing : When a program has no further use of a file, it should close it with
fclose( ) library function. The syntax of fclose( ) is as follows :
int fclose(FILE* fp)
The fclose( ) function closes the file associated with fp, which must be a valid file
pointer previously obtained using fopen( ), and disassociates the stream from the file.
It also destroys structure that was created to store information about file. The fclose( )
function returns 0 if successful and EOF (end of file) if an error occurs.
- Explain the procedure for Reading and Writing
Characters to a File in C.
- Explain String Handling (including declaration,
initialization and assignment) in C: Answer :
String Handling in C : We display strings on screen with printf( ) function. String
variables - the way C stores a string in a variable. Unlike variables of different
numeric data types, C follows a different approach to handle strings. [C stores a string
as an array of characters]. [An array is a group of contiguous memory locations, which
can store data of the same data type].
- Explain String Handling in Text Files (including
fputs( ) and fgets( ) functions) in C.
- Explain Formatted I/O in Files (including fprintf( )
and fscanf( ) functions) in C: Answer :
Formatted I/O in Files in C : The other two file handling functions to be covered are
fprintft( ) and fscanf( ). These functions operate exactly like printf() and scanf() except
that they work with files.
Their prototypes are :
int fprintf (FILE *fp, char *control_string, ...)
int fscanf (FILE *fp, char *control_string, …)
Instead of directing their I/O operations to the console, these functions operate on the
file specified by fp. Otherwise their operations are the same as their console based
relatives. The advantages to fprintf( ) and fscanf( ) is that they make it very easy to
write a wide variety of data to a file using a text format.
- Write a program to merge the contents of two text files.
- Write a program that counts the total number of characters in a text file. [Note:
consider the blank. space a character]
- Write a program that counts the number of words in a text files and display the
count on the screen.