delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/04/07:47:00

From: "A. Sinan Unur" <sinan DOT unur AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Simple beginner questions
Date: Wed, 03 Dec 1997 17:33:45 -0500
Organization: Cornell University http://www.cornell.edu
Lines: 52
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <3485DE49.CCFEE47D@cornell.edu>
References: <664c3s$2rq$1 AT fsuj19 DOT rz DOT uni-jena DOT de>
NNTP-Posting-Host: cu-dialup-0005.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019