On Tue, 23 Feb 1999, Mullen, Patrick wrote:

> You create a pointer, allocate memory to that pointer,
> set the data, then return the pointer.  The pointer
> itself loses scope and is lost, but the memory allocated
> remains.  You then have to make sure a function somewhere
> else frees the memory allocated.

  That's what's done on second example, rigth !?

> > /* This case (2)*/
> > main()
> > {
> >   char *exp ;
> > 
> >   exp = foo() ;
> > 
> >   printf("\n %s", exp);
> >   free(exp); 
> >   
> >   return(0) ;
> > }

  'exp' variable will contain the address from the allocated memory
and after that it will frees the memory.

 Thanks.

 Best regards,
    Nuno Carvalho

���������������������������������
   Nuno Emanuel F. Carvalho
 Dep. Informatics Engineering
    University of Coimbra

  PGP key available at finger
���������������������������������

Reply via email to