www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/07/19/08:45:04

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Re: Recursions and Static declarations....?Is this wrong...
Date: 19 Jul 2002 12:40:35 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 22
Message-ID: <ah91c3$5es$1@nets3.rz.RWTH-Aachen.DE>
References: <5a91d0ef DOT 0207181004 DOT 49e67056 AT posting DOT google DOT com> <ah8k0q$lqv$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <1027079317 DOT 518196 AT queeg DOT ludd DOT luth DOT se>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1027082435 5596 137.226.32.75 (19 Jul 2002 12:40:35 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 19 Jul 2002 12:40:35 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In comp.os.msdos.djgpp Martin Str|mberg <ams AT speedy DOT ludd DOT luth DOT se> wrote:
[...]
> Say I have this function:
[...]
> Wouldn't f(3) give a printout of 1, 2, 3, 4?

Yes. I'll admit I was quite uncorrect in my original answer.  But
then, so would the much simpler

> void f(int i)
> {
>   if(0 < i)
>     f(i-1);
>   printf("f: depth = %d.\n", i + 1);
> }

Counting recursions levels like in your example does work, but it can
be pretty pointless doing so if the recursion is controlled by an
integer parameter like in this example.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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