C

Fundamental concept of Problem solving
Introduction
Problem solving strategies
Program design & implementation
Introduction to C
Introduction to C
How to open C program code window
Description of C code window
Editing File
Saving and Running a program
The components of C language
Structure of C Program
A sample of C language program
C character set and keywords
C character set and keywords
The C character set
Identifiers
Key words
Data Types
Data Types
Primary Data Type
Secondary Data Type
Variables
Introduction
Rules for constructing variables names
Variable declaration
Assigning values to variables
Scope of variables: Local & Global
Constants
Introduction
Character constants
Integer constants
Real constants
Logical & String constants
C instruction set
Introduction
Type Declaration & Input/Output Instructions
Arithmetic Instructions
Control Instructions
Operators
Introduction
Arithmetic operators
Relational operators
Logical operators
Increment & Decrement operators
Bitwise operators
Conditional & ternary operators
The comma operators
Size of operator
Assignment operator
Type modifier
Expressions
Evaluation of expression
Automatic type conversion
Basic Input/Output
Introduction
Console I/O function
Disc & Port I/O function
Control Structures
Sequence control statements
Decision control & conditional statements
Case control statements
Repitition & loop control statements
Some more statements
Array and String
Introduction of Array
Array Declaration
Array Initialization
Two Dimensional Array
Multi Dimensional Array
String
Function and Recursion
Function Definition
Function Declaration
Function Call
Recursion
Pointers
Introduction
Pointer expression
Pointer & functions
Pointer & Array
Multi Dimensional Arrays & Pointer
Arrays of Pointer
Use of Pointer & functions
Structures
Introduction
Giving values to member
Structure Initialization
Comparison of structure variables
Arrays of structures
Arrays within structures
Structures within structures
Passing structure to function
Union
Introduction
Accessing a union member
Initialization of Union variable
Uses of Union
Dynamic Data Structure
Linked list
Stack
Queue
Data File Handling through C
Introduction
File operation
Opening & closing a data file
Creating a data file
Processing a data file
Unformatted data file
C Preprocessor & Macro
Introduction
Macro substitution directives
File inclusion
Compiler control directive
Command line parameter of C
Command line parameter
Header file
Header file
Use of library functions
Some Useful library functions

Data File Handling through C


Opening & closing a data file

When working with a stream-oriented data file, the first step is to establish a buffer area (a holt station for data processing) where information is temporarily stored while being transferred between the computer's memory and the data file.
 
This buffer area allows information to be read from or written to the data file more readily than would otherwise be possible. The buffer area is established by writing
 
FILE * ptvar;
 
Where FILE (uppercase letter required) is a special structure type that establishes the buffer area, and ptvar is a pointer variable that indicates the beginning of the buffer area.
 
The structure type FILE is defined within a system include file, typically stdio.h. The pointer ptvar is often referred to as a stream pointer, or simply a stream.
 
A data file must be opened before it can be created or processed. This associates the file name with the buffer area (i.e., with the stream).
 
It also specifies how the data file will be utilized, i.e., as a read-only file, a write -only file, or a read/write file, in which both operations are permitted.
 
The library function open is used to open a file. This function is typically written as Ptvar = open (file-name, file-type)
 
Where file-name and file-type are strings that represent the name of the data file and the manner in which the data file will be utilized.
 
The name chosen for the file-name must be consistent with the rules for naming files, as determined by the computer's operating system.
 
The file-type must be one of the strings shown:
 
 "r"  Open an existing file for reading only.
 "w"  Open a new file for writing only. If a file with the specified filename currently exists, it will be destroyed and a new file will be created in its place.
 "a"  Open an existing file for appending. A new file will be created if the file with the specified file-name don't exists.
 "r+"  Open an existing file for both reading and writing
 "w+"  Open an existing file for both reading and writing. If a file with the specified file name currently exists, it will be destroyed and a new file created in its place
 "a+"  Open an existing file for both reading and appending. A new file will be created if the file with the specified file-name does not exists.