Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Recursion

Node:Recursion, Next:, Previous:Data structures, Up:Top



Recursion

The program that swallowed its tail.

This chapter is about functions that call themselves. Consider the program below:

#include <stdio.h>

void black_hole()
{
  black_hole();
}

/* To shorten example, not using argp */
int main ()
{
  black_hole();
  return 0;
}

The main function calls the black_hole function, which calls itself, which calls itself, which calls... Once the control flow enters black_hole, it will never exit. This kind of function is called a recursive function, and a function's act of calling itself is called recursion.

 
 
  Published under free license. Design by Interspire