Teach Time Encyclopedia - Learn About Our World
Home Page
Teach Time
Featured Topics

United States
by state

CITYology

Academic Disciplines

Historical Timelines

Themed Timelines

Calendars

Reference Tables

Biographies

How-tos



Friday, October 10, 2008

Callback

In computer science, a callback is a concept, which allow a low level layer to call a function from a higher level layer, when usually, the higher level call the low level layer.

C Example

Here is an example in the C programming language

void counter( void (*cb)(int) )
{
   int i;
   for (i=15; i<20;i++)
   {
       cb(i);
   }
}

/** print number in hexadecimal */ void printHex(int i) { printf("%x\\n",i); }

/** print number in decimal */ void printDec(int i) { printf("%d\\n",i); }

int main(void) { void (*fn)(int); printf ("decimal:\\n") fn = &printDec; counter(fn); printf ("hexa:\\n") fn = &printHex; counter(fn);

return 0 }

Example result

decimal:
15
16
17
18
19
hexa:
f
10
11
12
13
14


Internet Hotel Solutions

Site Sponsors
AC Units
Baltimore Harbor
Boot Camp Grads
Bra Size
Burkittsville
College Hotels
Digital Harbor
Free Cell Phones
Golden Hare Travel
Golf Vacations
Golf Courses
Gourmet
Hair Styles
Hippodrome
iWoman
Lesson Plans
Maryland Hotels
MD Genealogy
Minor League Stuff
Motel Site
Ocean City
OC Real Estate
Old Agers
Office Supplies
Orlando
Pet Friendly Hotel
Room Prices
Savannah, GA
Ski Vacations
South Baltimore
Student Teaching
Travel Sources
University Hotels
Visit Military Bases
Washington, DC

Brought to you by NoChildLeftBehind.com and the Beaches and Towns Network, LLC.