POINTER IN C

Maha
Pointers in c programming


POINTER IN C

In C, a pointer is a variable that stores the memory address of another variable. A pointer essentially "points" to the location of another variable in memory.

Pointers have a lot of power because they let you directly change the values of other variables that are stored in memory.

Pointers, for instance, can be used to change the values of large arrays or structures without having to copy the entire structure. This can save time and memory.

In C, the * operator allows for the declaration of pointers.


There are major four types of pointers are:

1. Null Pointer.

2. Void Pointer.

3. Wild Pointer.

4. Dangling Pointer.


Syntax:

int *ptr;


Example:

#include <stdio.h>

int main() 

{

 int myHeight = 43;

 printf("%d\n", myHeight);

 printf("%p\n", &myHeight);

 return 0;

}

Output:

43

0x7fffa391e184

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send