As vishal pointed out, checking the return val is missing and it is the programmer's responsibility to free up the memory which he has requested for...
On Wed, Jun 22, 2011 at 7:37 PM, ankit sambyal <[email protected]>wrote: > @Vishal : Ya this seems to be correct.. > > > On Wed, Jun 22, 2011 at 7:05 AM, ankit sambyal <[email protected]> > wrote: > > @Balaji : the code given by u compiles and runs successfully in gcc > > compiler and gives the correct answer i.e. INDIAhyd . What's the > > problem ?? > > @Shachindra A C : Which memory leak are you talking about ?? The > > memory allocated from the heap using malloc need not be released > > before termination of the program. That's definitely not an error. The > > compiler does it automatically after the termination of the program... > > > > Correct me if I am wrong !! > > > > Regards, > > Ankit Sambyal > > BITS Pilani > > > > On Wed, Jun 22, 2011 at 6:34 AM, Shachindra A C <[email protected]> > wrote: > >> @balaji, the memory allocated from the heap using malloc needs to be > >> released before termination of the program. there should be two > additional > >> statements as follows: > >> free(p); > >> free(q); > >> > >> On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH <[email protected]> > >> wrote: > >>> > >>> @balaji > >>> > >>> I think memory leak is the only problem with the code. > >>> rest is fine > >>> > >>> On Wed, Jun 22, 2011 at 6:03 PM, Balaji S <[email protected]> > wrote: > >>>> > >>>> @pritpal : Refer ques 5 at > >>>> > http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html > >>>> > >>>> @shachindra : wats tat :-o > >>>> > >>>> -- > >>>> You received this message because you are subscribed to the Google > Groups > >>>> "Algorithm Geeks" group. > >>>> To post to this group, send email to [email protected]. > >>>> To unsubscribe from this group, send email to > >>>> [email protected]. > >>>> For more options, visit this group at > >>>> http://groups.google.com/group/algogeeks?hl=en. > >>> > >>> > >>> > >>> -- > >>> Regards > >>> Pritpal Singh Banga > >>> (RIT2008021) > >>> BTech ( IT ) , 6th Semester, > >>> Indian Institute of Information Technology > >>> Allahabad - 211012, India > >>> Official email : [email protected] > >>> Mobile: +91-9793907703 > >>> > >>> -- > >>> You received this message because you are subscribed to the Google > Groups > >>> "Algorithm Geeks" group. > >>> To post to this group, send email to [email protected]. > >>> To unsubscribe from this group, send email to > >>> [email protected]. > >>> For more options, visit this group at > >>> http://groups.google.com/group/algogeeks?hl=en. > >> > >> > >> > >> -- > >> Regards, > >> Shachindra A C > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "Algorithm Geeks" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]. > >> For more options, visit this group at > >> http://groups.google.com/group/algogeeks?hl=en. > >> > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Regards, Shachindra A C -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
