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 3398558
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:39:51+00:00 2026-05-18T04:39:51+00:00

This is basically just to help me understand pointers better, so if you guys

  • 0

This is basically just to help me understand pointers better, so if you guys can confirm/deny/explain anything it looks like I don’t understand properly I would be most appreciative. The examples of using mailboxes, and aunts, and streets, and all that crap is just confusing.

int a = 5;

int b = &a; // b will be the memory address of 'a'

int *c = a; // c will be the value of 'a' which is 5

int *d = &a; // d will be a pointer to the memory address of 'a'

int &e = a; // what would this be?


void FunctionA()
{
     int a = 20;
     FunctionB(&a);
     // a is now 15?
}

void FunctionB(int *a)
{
     a = 15;
}

Thank you guys for any help, I am just trying to improve my understanding beyond all of the crappy metaphor explanations im reading.

  • 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-18T04:39:51+00:00Added an answer on May 18, 2026 at 4:39 am

    I’ll take things one by one:

    int b = &a; // b will be the memory address of 'a'
    

    No. The compiler (probably) won’t allow this. You’ve defined b to be an int, but &a is the address of an int, so the initialization won’t work.

    int *c = a;
    

    No — same problem, but in reverse. You’ve defined c to be a pointer to an int, but you’re trying to initialize it with the value of an int.

    int *d = &a;
    

    Yes — you’ve defined d to be a pointer to an int, and you’re assigning the address of an int to it — that’s fine. The address of an int (or an array of ints) is what a pointer to int holds.

    int &e = a;
    

    This defines e to be a reference to an int and initializes it as a reference to a. It’s perfectly legitimate, but probably not very useful. Just for Reference, the most common use of a reference is as a function parameter (though there are other purposes, of course).

    void FunctionA() { int a = 20; FunctionB(&a); }
    void FunctionB(int *a) { a = 15; }
    

    To make this work, you need to change the assignment in FunctionB:

    void FunctionB(int *a) { *a = 15; }
    

    As it was, you were trying to assign an int to a pointer, which won’t work. You need to assign the int to the int that the pointer points at to change the value in the calling function.

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

Sidebar

Related Questions

I'm writing a simple linear linked list implementation in PHP. This is basically just
This is silly, but i can't understand how to do it. Checked out from
Im trying do this basically: var tr = document.createElement(tr); var td = document.createElement(td); td.appendChild(document.createTextNode('<input
What are the different types of encapsulation? Am I right in thinking this basically
I know that in C#, if you write ~MyClass() , this basically translates to
Basically this code below returns the right information, but I need to add the
I have written a secure TCP server in .NET. This was basically as simple
I'm not really sure how to title this question but basically I have an
Well basically I have this script that takes a long time to execute and
I basically want to do this: grep 'example.com' www_log > example.com.YYYY-MM-DD-H:i:S.log ...with of course

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.