File Processing File Operations In C, you can perform four major operations on the file, either text or binary: Creating a new file Opening an existing file Closing a file Reading from and writing information to a file • File Definition – File is a collection of record – Record is a collection of field – Field is a block of byte – Byte is collection of bit • Possible mode value : Mode Description “ r ” opening a file to be read. “ w ” creating a file to be written. “ a ” opening a File for data append. “ r+ ” opening a File for read/write. “ w+ ” creating file for read/write. “ a+ ” opening a File for read/append “rb” opening a File (binary) to be read. “wb” creating a file (binary) for write operation. • Closing a File using fcloseall(): ...
Structure And Union A structure is a user-defined data type available in C that allows to combining data items of different kinds. Structures are used to represent a record. Defining a structure: To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member. A union is a special data type available in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple purposes. Defining a Union: To define a union, you must use the union statement in the same way as you did while defining a structure. The union statement defines a new data type with more than one member for your program. SOURCE : Geeksforgeeks dan ppt binus maya