PPS Unit-5
PPS Unit-5
Download
Pdf Notes
Unit -5 Syllabus
A pointer is a variable that stores the memory address of another variable as its value.
A pointer can be used to store the memory address of other variables, functions, or even
other pointers.
Syntax:
Data_type *pname;
Int *p1;
Example:
printf("%d\n", myAge);
printf("%p\n", &myAge);
printf("%p\n", ptr);
Void Pointer:
A void pointer is a pointer that has no associated data type with it. A void pointer can hold an address of
any type and can be typecasted to any type.
Syntax:
Void *vp;
• Dynamic Memory Allocation refers to the process of allocating or deallocating memory blocks
during a program’s runtime.
• This is achieved through the use of four functions:
• A linked list is a dynamic data structure that consists of a series of nodes connected by
pointers.
• Each node contains data and a reference to the next node in the list.
• Unlike arrays, linked lists allow for efficient insertion or removal of elements from any
position in the list, as the nodes are not stored contiguously in memory.
Types of Linked Lists:
Singly Linked List Doubly Linked List Circular Linked List
• It is the simplest type of linked list • A doubly linked list or a two-way • A circular linked list is that in which
in which every node contains some linked list is a more complex type the last node contains the pointer
data and a pointer to the next of linked list that contains a to the first node of the list.
node of the same data type. pointer to the next as well as the • We can begin at any node and
• The node contains a pointer to the previous node in sequence. traverse the list in any direction
next node means that the node • Therefore, it contains three parts of forward and backward until we
stores the address of the next node data, a pointer to the next node, reach the same node we started.
in the sequence. A single linked list and a pointer to the previous node. Thus, a circular linked list has no
allows the traversal of data only in This would enable us to traverse beginning and no end.
one way. the list in the backward direction
as well.
File Handling
• File handing in C is the process in which we create, open, read, write, and close operations on a file.
• C language provides different functions to perform input, output, and many different C file operations in our program.
Types of Files in C
A file can be classified into two types based on the way the file stores the data. They are as follows:
• Text Files:
A text file contains data in the form of ASCII characters and is generally used to store a group of characters.
It can be read or written by any text editor.
They are generally stored with .txt file extension.
• Binary Files:
A binary file contains data in binary form (i.e. 0’s and 1’s) instead of ASCII characters.
More secure as they are not easily readable.
They are generally stored with .bin file extension.
Operatons on Files:
File Opening Modes:
C program to copy contents of one file to another file
Preprocessor
A preprocessor is a program that processes its input data to produce output that is used as input
in another program.
C Preprocessor Directives:
In almost every C program we come across, we see a few
lines at the top of the program preceded by a hash (#) sign.
They are called preprocessor directives.
They are preprocessed by the preprocessor before actual
compilation begins.
Example -
Defining a macro
Using
#define
2. #include – File Inclusion Directive
Example - File
inclusion
directives
3. #if, #ifdef, #else, #elfi, #endif – Conditional Compilation: