Skip to main content

Types of pointers

Types of pointers

NULL pointer


if a pointer does not point to any variable, it can be initialized to NULL to indicate that it does not hold any valid address. 
Example: int *ptr=NULL; 

Dangling pointer


 A pointer which holds the address of a variable which no longer exists, is a dangling pointer. Example: 
void main() 
{ int *ptr; 
{ int num=10; 
ptr=# 
}

//num is destroyed 
//ptr is still holds address of num so it is dangling pointer. 

}

Generic/void pointer


A pointer which points to ‘void’ data type is called a generic pointer. In ‘C’, void represents the absence of type, so void pointers are pointers that point to a value that has no type. This allows void pointers to point to any data type. 
Example: 
void *ptr; 

(int *)ptr=&n; 

Uninitialized/wild pointer


A pointer which has not been assigned any address till it is first used in a program is called an uninitialized or wild pointer. It contains some garbage value.
Near pointer: A near pointer is a 16 bit pointer (2 byte) to an object contained in the current segment, be it code segment, data segment, stack segment, or extra segment. Hence it can access only 216memory locations i.e. 65536 bytes(64KB).


Near pointer


 A near pointer is a 16 bit pointer (2 byte) to an object contained in the current segment, be it code segment, data segment, stack segment, or extra segment. Hence it can access only 216memory locations i.e. 65536 bytes(64KB). 
Example: int near *ptr; 

Far pointer


A far pointer is 4 bytes (32 bits) and can access memory outside the current segment. A far pointer is a 32 bit pointer to an object anywhere in memory. Example: int far *ptr; 

Huge pointer


Like the far pointer, huge pointer is also typically 32 bits and can access memory outside the current segment. Huge pointer can access multiple segments of memory. 
Example: int huge *ptr;

Comments

Trending⚡

Understanding link.click() in JavaScript

Hey! Today i am going to share with you how to use link.click() function in javascript As a JavaScript developer, you may come across the need to programmatically click a link on a web page. The link.click() method is a commonly used way to do this, and it is important to understand how it works and when to use it. What is link.click()? link.click() is a method that can be used to simulate a click on a link element in JavaScript. It is typically used when you want to trigger a link click event programmatically, rather than requiring the user to physically click the link. How to use link.click() Using link.click() is relatively straightforward. First, you need to select the link element you want to click using a DOM selector such as getElementById() or querySelector(). Then, you can call the click() method on the link element to simulate a click. Here is an example: // select the link element const myLink = document.getElementById('my-link'); // simulate a cl...

Policy vs Innovation Matrix - India

Policy vs Innovation Matrix Policy vs Innovation Matrix that shows the structural difference between policy intent and actual innovation output — and how India’s model is transforming to match global innovation systems . From Paper Policies to Product Power 🧱 Traditional Indian Model (Old System) Policy Layer Reality Innovation Outcome Policy Vision Strong national policies Vision without execution pipelines Funding Govt-dominated funding Limited capital availability Risk Culture Risk-averse systems No deep-tech experimentation Research Academic publications Low commercialization Industry Role Minimal R&D involvement Weak private innovation Infrastructure Limited labs & compute Research bottlenecks Talent High-quality brains Brain drain Commercialisation Weak tech transfer Research stays in journals Scale Fragmented schemes No national scale impact Speed Slow approvals Innovation delays Result: ➡ Policy existed ➡ Innovation did not scale ➡ Research stayed inside institutions ...

India’s Landmark Era of Research, Innovation & Deep-Tech Growth

India’s research and development (R&D) ecosystem is undergoing a historic transformation. The country is shifting from a primarily public-funded research model to a private-sector-driven, innovation-led economy , backed by massive strategic investments. This transformation directly supports the national vision of Viksit Bharat @ 2047 , with Investment and Innovation identified as two of the four core growth engines in the 2025–26 Union Budget . The focus is clear: ➡ Build global innovation leadership ➡ Strengthen deep-tech infrastructure ➡ Attract private capital into strategic sectors ➡ Create a strong research-to-commercialisation pipeline 🧠 Strategic Institutional Foundations Anusandhan National Research Foundation (ANRF) Operational since 2024 Target: ₹50,000 crore mobilisation over 5 years Purpose: Bridge academia–industry collaboration Provide strategic national direction in science & technology Enable interdisciplinary research to solve complex societal challenges R...

Pointer const and Constant Pointer

A constant pointer is a pointer that cannot change the address which it stores.   Syntax: datatype *const pointer_name;  Example:  int a=10,b=20;  int *const ptr;  ptr=&a;  ptr=&b; //here the address in ptr cannot be changed so not allowed . Pointer to constant  Address in the pointer can be changed but the value of the data element which the pointer points cannot be changed.  Syntax: const datatype * pointer_name;  Example:  int a=10,b=20;  const int *ptr=&a;  *ptr=100; //here the value which ptr points to cannot changed so not allowed ptr=&b; //allowed Pointers and Const  The previous two can be combined to form a constant pointer to constant  Syntax: const datatype *const pointer_name; Example:  const int * const ptr;  int a=10,b=20;  const int * const ptr=&a;  *ptr=100; //not allowed  ptr=&b;//not allowed  Here the value which ptr points to cannot be changed an...

Basics of Decoder

Basics of Decoder  Decoder is a combinational logic circuit that converts abinary code into the desired output signals. It is called decoder because it performs the reverse process of encoder. The process of converting binaryinput code into desirable output is known as decoding.  Figure 1 is the logic symbol of decoder with ‘n’ inputs and ‘m’ outputs. In short, it is multiple inputs and multiple outputs device with proper conversion system.  Note that decoder performs the reverse operation of the encoder. A decoder has ‘n’ number of input lines and ‘m’ number of output lines. There are 2n possible input combinations and the number of outputs (m) are less than or equal to 2n. Decoder converts an n bit code to single active output. The information present in one code is obtained back into the desired code. In general Decoder is circuit which convert specific code into more general form of code. A decoder is a logic circuit that accepts a set of inputs that represents a bina...

Linked List Data Structure

Linked List Prerequisites for Linked List Definition of linkedlist Important points of Linked List Types of Linked List Basic Operations performed on Linked List Difference Between Linked List and Arrays Drawbacks of Linked List Applications of Linked List In real world Singly Linked List in C Doubly Linked List in C Singly Circular Linked List in C Doubly Circular Linked Listist in C Add node in Singly Linked List Display Data of Linked List Deletion of a node from linked list Prerequisites for Linked List pointer concept (*ptr) Address Operator (&ptr) Pointer A pointer is a variable which stores the address of another variable. By using a pointer we can directly access the memory address of the variable. Like any variable or constant, you must declare a pointer before using it to store any variable address. The general form of a pointer variable declaration is type *variable-name; Here, type is the pointer...