[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

returning an address in memory

Posted on 2006-05-10
4
Medium Priority
?
410 Views
Last Modified: 2008-02-01
What ways can a function return an address in memory that are acceptable? Which ways are unacceptable?
0
Comment
Question by:luoys
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
steveiam earned 2000 total points
ID: 16654569
What language are you using? Is there any more context to your question?  What are you intending to do with the pointer after its returned?

If you're using C/C++, returning an address in memory is what happens when you return a pointer.  Generally, you want to return a pointer to memory that someone "owns", i.e. not unallocated memory.

Because of the way C/C++ works, a lot of things are referred to by pointers, and its fairly unavoidable.  In these cases its normal to pass and return pointers.
0
 

Expert Comment

by:rubentrancoso
ID: 16656815
A function can return a pointer to the address. It's acceptaple. A pointer is a integer that maps to a memory location. Anything that can be translatade to a integer is acceptable.
0
 

Author Comment

by:luoys
ID: 16662465
In C++ besides pointer, I think a function can also return an address in memory by reference. Is that correct? Is there any other way to return an address in memory?
0
 

Expert Comment

by:rubentrancoso
ID: 16662742
A pointer IS a address in memory referenced by a integer. If you pass a address of a integer you can cast it to a void pointer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question