Current location: Hot Scripts Forums » Programming Languages » C/C++ » memory leaks and dyanimic allocation pitfalls


memory leaks and dyanimic allocation pitfalls

Reply
  #1 (permalink)  
Old 08-16-09, 12:02 AM
baddy baddy is offline
New Member
 
Join Date: Aug 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
memory leaks and dyanimic allocation pitfalls

please clarify whether my understanding of the following code is proper


#include..

void main()
{
int *p;

p=(int*)malloc(10*sizeof(int));
*p=100;
p=(int*)malloc(10*sizeof(int));

.....
.
.}


now the memory allocated in heap is 40 bytes or will it be twice of it....

and the value will be a garbage value or it will be 100


PLEASE EXPLAIN....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 09:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.