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

memory leaks and dyanimic allocation pitfalls

 
Prev Previous Post   Next Post Next
  #1  
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....
Reply With Quote
 

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

Forum Jump


All times are GMT -5. The time now is 07:32 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)