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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:10:55+00:00 2026-05-23T23:10:55+00:00

If I have the following for example: int *x; x = func(a); For the

  • 0

If I have the following for example:

int *x;
x = func(a);

For the statement: x = func(a);, do we say that we are returning an address to x? Or, how exactly do we read it?

EDIT: Is it eligible to say that we are returning a pointer to x? If so, can you explain how this is done exactly? I mean, how are we returning a pointer?

  • 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-23T23:10:56+00:00Added an answer on May 23, 2026 at 11:10 pm

    x is a pointer, specifically to an int. So it should be obvious that there are two memory locations used. One for the pointer and one for the memory it’s pointing to (assuming the pointer is not null).

    The pointer itself holds a memory address, specifically the location of the memory it’s pointing to. Something like 0xa456e4fa.

    Yes, func() is returning a pointer. The prototype of func would look like the following..

    int * func(someObj a); //I don't know the datatype of your parameter,
                           //so I'm just making something up.
    

    Notice the return type is a pointer to an int. From this and what I said previously, it should be obvious what this will return. Something of the form 0xyyyyyy, or a memory address/pointer. That memory address goes into your x pointer.

    Remember that the pointer itself is not holding the data that it’s pointing to, it is only the address. There’s really no reason you CAN’T return a pointer. However, you do need to be careful in WHAT you return. You do not want to return the address of a local variable because that variable will go out of scope once the function has completed its execution. You’ll then be returning the address of something invalid. Returning the VALUE of a local pointer however, is fine because the value you returned (the address) will be preserved as will the memory it’s pointing to.

    I also just realized I wrote you a book. Damn, I sure do ramble when I’m tired.

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

Sidebar

Related Questions

I have the following example, compiled in VS2005, warning level 4: int main(int argc,
If i have the following code example: public class ClassBase { public int ID
Consider following example. #include <iostream> #include <algorithm> #include <vector> #include <boost/bind.hpp> void func(int e,
I have the following: Expression<Func<Car, int>> myExpr = car => car.Wheel.Tyre.Pressure; I want to
I have the following example in C: int x = 123; size of int
I have the following example code: create table Details( name varchar(20), age int, weight
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
I have the following example code: create table #tempmembers ( memberid int ) update
I have created a repository method with the following signature: T Get<TProperty>(int id, Expression<Func<T,
i have a question about the function call in the following example: int main()

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.