473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

printing an address with Write function

2
Hello,

So I'm trying to create a malloc function and want to print some addresses to check on them and be able to visualize a little what's going on but I can't use printf cause it messes around my process's heap which I don't want.
I was wondering how I could use the write function to print an address recovered from a pointer.
Thanks
Oct 7 '08 #1
4 1600
JosAH
11,448 Expert 8TB
Why does printf("%p", your_pointer) mess around in the heap?

kind regards,

Jos
Oct 7 '08 #2
TuRu87
2
because it uses the malloc from the standard library. In fact when I execute the following code:

printf("%p\n", sbrk(0));
printf("%p\n", sbrk(0));

I get:

0x804979c
0x804c000

Which means that when the 1st printf is executed the 'break' indicating the end of the heap is moved (I think).
Oct 7 '08 #3
JosAH
11,448 Expert 8TB
What happens if you first execute "free(malloc(4096))" first?

kind regards,

Jos
Oct 7 '08 #4
donbock
2,426 Expert 2GB
because it uses the malloc from the standard library. In fact when I execute the following code:

printf("%p\n", sbrk(0));
printf("%p\n", sbrk(0));

I get:

0x804979c
0x804c000

Which means that when the 1st printf is executed the 'break' indicating the end of the heap is moved (I think).
What sort of behavior caused you to instrument your code like this?
Oct 8 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stephen Briley | last post by:
Hi all, I would like to write a python script that takes input of 2 ip address, one a start address and the other the end address and prints a list of all ip address in between in...
10
by: Andrew | last post by:
I am making a web site and I am using ASP because of its templating capabilities. My footer is an include file, for obvious reasons. I can't use an include file for the header, because, while the...
1
by: BJS | last post by:
Sorry for the cross-posting, but based on the number of people I have seen ask for a solution to this problem, I hope by cross-posting this, that it will help a lot of people out of a common...
42
by: Prashanth Badabagni | last post by:
Hi, Can any body tell me how to print "hello,world" with out using semicolon Thanks in advance .. Bye Prashanth Badabagni
42
by: junky_fellow | last post by:
Consider an implementation that doesn't use all bits 0 to represent a NULL pointer. Let the NULL pointer is represented by 0x12345678. On such an implementation, if the value of NULL pointer is...
7
by: ap | last post by:
Hi, It is a quick question... Is that impossible to print the page(Web Form .aspx file) in client side using GDI+ like PrintDocument pd = new PrintDocument(); pd.print(); As I know it is a...
7
by: salmonella | last post by:
Hi, I'm trying to print on screen an address of class member function (the function of certain object of course). My code looks like this: class MyClass { public: void fun(void){}; };
57
by: Robert Seacord | last post by:
i am trying to print the address of a function without getting a compiler warning (i am compiling with gcc with alot of flags). if i try this: printf("%p", f); i get: warning: format %p...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.