pointers

//pointer: variable which stores the address of another variable
//pointer in c programming language can be declared using * (astric symbol)

// NULL pointer: a pointer that is not assigned any value but NULL is known as the NULL pointer
// * : it is the dereference operator (also called indirection operator) used to get the value at a given address
// & : the address of operator '&' returns the address of a variable

#include <stdio.h>
int main()  
{
    printf("lets learn about pointers\n");
    int a=75;
    int *ptr=&a; // ptr points to a (pointer)
    int *ptr2=NULL; // NULL pointer
    int *ptr3; //garbage address(not used) if here we use NULL this will not become garbage

    printf("the value of a is %d\n",*ptr);
    printf("the address of a is %d\n",ptr);//|this both are same
    printf("the address of a is %d\n",&a);   //|
    printf("the address of pointer to a is %d\n",&ptr);
   
    printf("the address of null pointer is %d\n",ptr2);
    printf("the address of garbage pointer is %d\n",ptr3);
    return 0;
}

Comments

Popular posts from this blog

Tokens in C

Steps taken by a compiler to execute a C program

Variables and Data Types in C