Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: Disabled
Using malloc and getting memory address


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, 10:03 AM   #2
Senior Member
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 3,273

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

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


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 01:17 PM
In Linux2.6, why does malloc return high memory address(higher than 0x40000000) ? zanshigang Linux - Kernel 0 10-11-2010 05:11 AM
C, Malloc, and Memory: Just Curious CoderMan Programming 4 01-20-2010 09:17 PM
malloc() and system memory spaceman27 Programming 8 04-25-2005 09:58 AM
Out Of Memory - A caring malloc? cyent Programming 3 09-18-2002 09:38 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:18 PM.

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