A pointer in C is a variable that holds the memory address of another variable. A single pointer, also known as a "regular" pointer, can hold the memory address of a single variable.
The basic syntax for declaring a pointer in C is as follows:
data_type *pointer_name;
Here, the data_type specifies the data type of the variable the pointer will be pointing to, and the pointer_name is the name of the pointer. The * operator is used to indicate that the variable is a pointer.
Here is an example of a single pointer being used in a program:
This program demonstrates how to declare and initialize a single pointer, how to set it to the memory address of a variable, how to print the value stored at a memory address and how to dereference a pointer variable.
#include<stdio.h> int main() { int a=10,*p; p=&a; //Address of a printf("\n Value of A : %d",a); printf("\n Address of A : %d",&a); printf("\n Value of P : %d",p); printf("\n Address of P : %d",&p); printf("\n P Dereferencing : %d",*p); return 0; }To download raw file Click Here
Value of A : 10 Address of A : 6356732 Value of P : 6356732 Address of P : 6356728 P Dereferencing : 10
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions