CSE Dept Engineering Topics List

Syntax with Example C Programs

Subject and UNIT: Programming in C: Unit V: File processing

When reading or writing data from files, we often do not know exactly how long the file is. For example, while reading the file, we usually start reading from the beginning and proceed towards the end of the file.

Syntax with Example C Programs

Subject and UNIT: Programming in C: Unit V: File processing

C provides the following set of functions to read data from a file: • fprintf(), • fputs(), • fputc(), • fwrite().In this section, we will read about these functions.

Syntax with Example C Programs

Subject and UNIT: Programming in C: Unit V: File processing

C provides the following set of functions to read data from a file. • fscanf(),• fgets(),• fgetc (),• fread().In this section, we will read about these functions.

Syntax with Example C Programs

Subject and UNIT: Programming in C: Unit V: File processing

There can be a number of files on the disk. In order to access a particular file, you must specify the name of vistars the file that has to be used.Programming Tip: An error will be generated if you use the filename to access a file rather than the file pointer.

File processing in C Programming

Subject and UNIT: Programming in C: Unit V: File processing

A file is a collection of data stored on a secondary storage device like hard disk. Till now, we had been processing data that was entered through the computer's keyboard. But this task can become very tedious especially when there is a huge amount of data to be processed.

Programming in C

Subject and UNIT: Programming in C: Unit IV: Structures and Union

A singly linked list is the simplest type of linked list in which every node contains some data and a pointer to the next node of the same data type. By saying that the node contains a pointer to the next node we mean that the node stores the address of the next node in sequence.

Programming in C

Subject and UNIT: Programming in C: Unit IV: Structures and Union

We have seen how a linked list is represented in memory. If we want to add a node to an already existing linked list, we will first find free space in the memory and then use it to store the information.

with Example C Programs

Subject and UNIT: Programming in C: Unit IV: Structures and Union

The enumerated data type is a user-defined type based on the standard integer type. An enumeration consists of a set of named integer constants. In other words, in an enumerated type, each integer value is assigned an identifier.

with Example C Program

Subject and UNIT: Programming in C: Unit IV: Structures and Union

C also allows users to have a structure within a union. The program given below illustrates the use of structures within a union. There are two structure variables in the union. The size of the union will be size of structure variable which is larger of the two.

with Example C Program

Subject and UNIT: Programming in C: Unit IV: Structures and Union

You must be wondering, why do we need unions? Generally, unions can be very useful when declared inside a structure. Consider an example in which you want a field of a structure to contain a string or an integer, depending on what the user specifies.

with Example C Program

Subject and UNIT: Programming in C: Unit IV: Structures and Union

Like structures we can also have an array of union variables. However, because of the problem of new data overwriting existing data in the other fields, the program may not display the accurate results.

Syntax with Example C Programs

Subject and UNIT: Programming in C: Unit IV: Structures and Union

Similar to structures, a union is a collection of variables of different data types. The only difference between a structure and a union is that in case of unions, you can only store information in one field at any one time.