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
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

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




The GNU C Programming Tutorial - Recursion

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


The program that swallowed its tail.

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

#include <stdio.h>

void black_hole()

/* To shorten example, not using argp */
int main ()
  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