Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
BlueHost Web Hosting

Bonsai Boy of New York Bonsai Trees and Accessories

Website Domains Names & Hosting | Domain.com

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

DreamHost Web Hosting


Instant Grammar Checker - Correct all grammar errors and enhance your writing

Liquid Web Cloud VPS Hosting

Disclosure We are a professional Information website that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

12,195 questions

16,607 answers

573 users

How to use const pointer to pointer in C

Online Web Development & Programming Courses | Udemy
17 views
asked Jul 28, 2017 by avibootz
retagged Aug 3, 2017 by avibootz

9 Answers

0 votes
#include <stdio.h>
  
int main(void)
{
    int n = 100;
    const int *p;
    const int **pp;
  
    pp = &p; 
    *pp = &n; 
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);

    return 0;
}
  
    
/*
run:
   
n = 100
*p = 100
**pp = 100
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n;
    const int *p;
    const int **pp;
  
    pp = &p; 
    *pp = &n;
    **pp = 13; // error: assignment of read-only location

    return 0;
}
  
    
/*
run:
   
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n = 98;
    int *p;
    int * const *pp;
  
    pp = &p; 
    *pp = &n; // error: assignment of read-only location ā€˜*pā€™ 

    return 0;
}
  
    
/*
run:
   
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n;
    int *p;
    int * const *pp;
  
    p = &n;
    pp = &p; 
    **pp = 900; 
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);

    return 0;
}
  
    
/*
run:
   
n = 900
*p = 900
**pp = 900
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n = 100;
    int *p;
    int ** const pp = &p; 
    
    pp = &p; // error: assignment of read-only variable 'pp'

    return 0;
}
  
    
/*
run:
   
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n;
    int *p;
    int ** const pp = &p; 
    
    *pp = &n; 
    **pp = 30; 
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);
  
    return 0;
}
  
    
/*
run:
  
n = 30
*p = 30
**pp = 30
 
*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n = 99;
    const int *p;
    const int * const *pp;
    
    p = &n;
    pp = &p;
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);
  
    return 0;
}
  
    
/*
run:
  
n = 99
*p = 99
**pp = 99

*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n = 10;

    const int *p;
    const int ** const pp = &p; 
  
    *pp = &n; 
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);
  
    return 0;
}
  
    
/*
run:
  
n = 10
*p = 10
**pp = 10

*/

 




answered Jul 28, 2017 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    int n;
    int *p;
    int * const * const pp = &p; 
  
    p = &n;
    
    **pp = 88; 
    
    printf("n = %d\n", n);
    printf("*p = %d\n", *p);
    printf("**pp = %d\n", **pp);
  
    return 0;
}
  
    
/*
run:
  
n = 88
*p = 88
**pp = 88

*/

 




answered Jul 28, 2017 by avibootz
...