difference between single star and multi star in pointer code example

Example 1: pionter in c++

#include <iostream>
using namespace std;
int main(){
   //Pointer declaration
   int *p, var=101;
 
   //Assignment
   p = &var;

   cout<<"Address of var: "<<&var<<endl;
   cout<<"Address of var: "<<p<<endl;
   cout<<"Address of p: "<<&p<<endl;
   cout<<"Value of var: "<<*p;
   return 0;
}

Example 2: double pointers C++

#include <stdio.h>

int main(void)
{
    int value = 100;
    int *value_ptr = &value;
    int **value_double_ptr = &value_ptr;

    printf("Value: %d\n", value);
    printf("Pointer to value: %d\n", *value_ptr);
    printf("Double pointer to value: %d\n", **value_double_ptr);
}

Tags:

Cpp Example