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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:39:03+00:00 2026-05-17T01:39:03+00:00

I am a little confused as to how passing pointers works. Let’s say I

  • 0

I am a little confused as to how passing pointers works.

Let’s say I have the following function and pointer, and…

EDIT:

…I want to use a pointer to some object as an argument in the function.

i.e.:

void Fun(int Pointer){
    int Fun_Ptr = ---Passed Pointer---; 
    //So that Fun_Ptr points to whatever ---Passed Pointer points to

Between the *Pointer and &Pointer notations, I am very confused. I know that *Pointer means give whatever it points to.

Do I put void (int *pointer) in the declaration. What about when I use the function?

Your assistance is appreciated.

EDIT 2:

Okay, I now understand that using *variable in a declaration means that a pointer will be passed. However, what about when i use the function?

i.e.

int main(){
    int foo;
    int *bar;
    bar = foo;
    Fun(bar);
}

EDIT 3:
Okay, so correct me if I am wrong:

According to the conventions of the above code:

bar = &foo means: Make bar point to foo in memory

*bar = foo means Change the value that bar points to to equal whatever foo equals

If I have a second pointer (int *oof), then:

bar = oof means: bar points to the oof pointer

bar = *oof means: bar points to the value that oof points to, but not to the oof pointer itself

*bar = *oof means: change the value that bar points to to the value that oof points to

&bar = &oof means: change the memory address that bar points to be the same as the memory address that oof points to

Do I have this right?

EDIT 4: Thanks so much for all your help (I wish I could accept more than 1 answer, but I have to go with the first one. I am not sure how a community wiki works exactly, but I will leave it this way for editing (feel free to turn it into a ref guide if you like).

  • 1 1 Answer
  • 1 View
  • 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-17T01:39:04+00:00Added an answer on May 17, 2026 at 1:39 am

    There is a difference in the * usage when you are defining a variable and when you are using it.

    In declaration,

    int *myVariable;
    

    Means a pointer to an integer data type. In usage however,

    *myVariable = 3;
    

    Means dereference the pointer and make the structure it is pointing at equal to three, rather then make the pointer equal to the memory address 0x 0003.

    So in your function, you want to do this:

    void makePointerEqualSomething(int* pInteger)
    {
        *pInteger = 7;
    }
    

    In the function declaration, * means you are passing a pointer, but in its actual code body * means you are accessing what the pointer is pointing at.

    In an attempt to wave away any confusion you have, I’ll briefly go into the ampersand (&)

    & means get the address of something, its exact location in the computers memory, so

     int & myVariable;
    

    In a declaration means the address of an integer, or a pointer!

    This however

    int someData;    
    pInteger = &someData;
    

    Means make the pInteger pointer itself (remember, pointers are just memory addresses of what they point at) equal to the address of ‘someData’ – so now pInteger will point at some data, and can be used to access it when you deference it:

    *pInteger += 9000;
    

    Does this make sense to you? Is there anything else that you find confusing?

    @Edit3:

    Nearly correct, except for three statements

    bar = *oof;
    

    means that the bar pointer is equal to an integer, not what bar points at, which is invalid.

    &bar = &oof;

    The ampersand is like a function, once it returns a memory address you cannot modify where it came from. Just like this code:

    returnThisInt("72") = 86; 
    

    Is invalid, so is yours.

    Finally,

    bar = oof
    

    Does not mean that “bar points to the oof pointer.” Rather, this means that bar points to the address that oof points to, so bar points to whatever foo is pointing at – not bar points to foo which points to oof.

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

Sidebar

Related Questions

Im a little bit confused about passing structs into functions. I understand pointers and
I have been doing some reading and a little bit confused, let me explain.
I am a little confused about Accept-Encoding . I have Web Service which would
I'm getting a little confused with using Absolute and Relative positioning. Basically I have
I'm a little confused here, I am trying use a partial view in a
OK, I am a little confused. I have a subclass of UIScrollView, which is
I'm a little confused on how to use hidden fields for persisting data in
I'm a little confused about how to use the cursor to access the data
I'm a little confused about how to pass an object to the pthread_create function.
I am a little confused with intent and message passing in android.Basically my current

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.