[Ilugc] C pgm - Recursive -segmentation fault

  • From: lug@xxxxxxxxxxxxxxxxxx (Chandrashekar Babu)
  • Date: Mon Sep 13 23:45:02 2004

But tell me an recursive function shld run forever(atleast in theory) right
??? 

Perhaps you are trying to use a structured programming language to implemented 
a functional programming paradigm. If you are inclined towards writing programs 
using intoxicating amounts of recursion, you must either be writing them using 
haskell or LISP. But then, they too have their limitations. Any recursive block 
must end at some point either by a condition-check, or run till your system 
bails out of memory (or stack-space, precisely).

Consider a case where my program does something repeatedly ..in such a case
I write a recursive program .what's the point in writing a recursive
function if it is going to exit abruptly.

If your task is to run a function repeatedly forever, you must redesign the 
function using iterative constructs (using while(), for(), do() or *gasp* goto, 
in C).

Cheers,
Chandrashekar Babu.

Other related posts: