Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:19:45+00:00 2026-05-26T08:19:45+00:00

Have a look at this code snippet: int i = 10; int *pi =

  • 0

Have a look at this code snippet:

int i = 10;
int *pi = &i;
int **ppi = π // first declaration
int *api = pi;   // second declaration

printf("i's value is: %d\n",i);
printf("pi's value is: %d\n",*pi);
printf("ppi's value is: %d, at the address: %d\n",**ppi);
printf("api's value is: %d, at the address: %d\n",*api);

Output

$ ./test
i's value is: 10
pi's value is: 10
ppi's value is: 10, at the address: 2686760
api's value is: 10, at the address: 2686760

So which way is (perhaps) more preferrable in those 2 declarations of pointer to pointer, and is there any technical difference between those two?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:19:45+00:00Added an answer on May 26, 2026 at 8:19 am

    Technically, you’ve only declared one pointer-to-pointer.

    int **ppi = π // first declaration
    

    The second declaration is just a pointer which, when assigned, gets a copy of the first pointer pi‘s address.

    Here’s how you can prove it; after your test code, add this:

    int i2 = 20;
    pi = &i2;
    
    printf("ppi's value is: %d, at the address: %d\n",**ppi,*ppi);
    printf("api's value is: %d, at the address: %d\n",*api,api);
    

    The output will be:

    ppi's value is: 20, at the address: 2686764 (or some other address)
    api's value is: 10, at the address: 2686760
    

    When you change the value of pi (what it points to), dereferencing ppi will reflect the changes, as it points to pi, but because api was just made as a copy of pi before it changed, it will continue pointing to i.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a look at this code snippet struct S{ int i; int j;}; int
Have a look to this code snippet:- CommonService objcommonService; NetworkCredential myCredentials = new NetworkCredential(144552,
Have a look to this code snippet:- -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength:
I have code that I want to look like this: List<Type> Os; ... foreach
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
What is the purpose of the Source attribute? Have a look at this snippet:
I have blocks of code that look like: ICar car = new Car<int>(10); var
Look at the code snippet: This is what I normally do when coding against
Quick one folks. Have a quick look at the code snippet below. I alloc
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.