Mail Archives: djgpp/1997/12/04/07:47:00
E. Schmidt wrote:
>
> Hallo World!
hello yourself. i would first like to point out that the questions you
posted are off-topic for this ng. you are better off trying a c group
such as news:comp.lang.c or news:comp.lang.c.moderated. also, take a
look at the the C faq (which you is frequently posted to those groups.
you can also search yahoo for the web site.)
> 1. How to define user function with variable
> number of arguments? I simply want(ed) to
> define my error handler printing some formatted message
> and making some other things like closing files...
IMHO, you should separate printing errors from actually handling errors.
for variable argument lists, take a look at the stdarg.h file, and
documentation pertaining to that functionality. take a look at the C
faq.
> 2. How to close the file, if I don't know if it is opened or closed?
> Only file variable FILE * fp; is achivable.
make a habit of setting fp to NULL after closing it. AFAIK, files do not
close themselves.
> 3. Is it important in C to free the memory in the inverse
> allocation order ?
> p1=malloc(100);
> p2=malloc(200);
> ...
> free(p2);
> free(p1);
i don't think so. although it might matter for storage efficiency.
> For above example
> free(p1);
> p1=malloc(50);
> Would these 50 bytes be allocated in the memory of previous
> malloc(100) ?
take a look at realloc.
--
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA
mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/
- Raw text -