LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-10-2011, 10:49 AM   #1
southpau1
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Rep: Reputation: Disabled
Using malloc and getting memory address


Hello-

I am trying to use malloc. I understand that when calling malloc, it returns a pointer to the memory address of the allocated memory.

How would I go about getting the ACTUAL memory address that the pointer is pointing to in the format of 0xc0000000..?
 
Old 11-10-2011, 11:03 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,935

Rep: Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524Reputation: 524
printf ("malloc returned %p\n", p);
 
1 members found this post helpful.
Old 11-10-2011, 11:14 AM   #3
southpau1
LQ Newbie
 
Registered: Sep 2011
Posts: 24

Original Poster
Rep: Reputation: Disabled
Thank you!!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory leaks.. *** glibc detected *** ./SuffixTree: malloc(): memory corruption: 0x00 evansash Programming 12 03-21-2011 02:17 PM
In Linux2.6, why does malloc return high memory address(higher than 0x40000000) ? zanshigang Linux - Kernel 0 10-11-2010 06:11 AM
C, Malloc, and Memory: Just Curious CoderMan Programming 4 01-20-2010 10:17 PM
malloc() and system memory spaceman27 Programming 8 04-25-2005 10:58 AM
Out Of Memory - A caring malloc? cyent Programming 3 09-18-2002 10:38 AM


All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration