"Tcl is designed to be easily extensible by writing new command
implemetations in C. A command implemented in C is more efficient than
an equivalent TCL procedure. A more pressing reason to write C code is
that it may not be possible to provide the same functionality purely in
TCL."
Practical Programming in Tcl and Tk - DRAFT, 13
January 1995; Brent Welch
Tk is an extension toolkit for X windows. It defines TCL commands that let you create and manipulate UI widgets. It too can be extended in a similar manner as Tcl by C.
The integration of C and both Tcl and Tk are very similar to each other. The libraries: tcl.h and tk.h have to be included in the main C program and then the respective interpreter is created by using either the function: Tcl_Main or Tk_Main. You can make it either read a script (Tcl or Tk) or enter an interactive loop.
Detailed explanations of this can be found in the book.
In this example from my third year project, Tcl/Tk procs are registered into the C program using the Tcl_CreateCommand procedure call within a Tcl_AppInit procedure. The main procedure calls the "start" Tcl/Tk script which kicks off the GUI application.
main.c does not actually include tcl.h and tk.h because they are in iface.h
Most of the information used for this section has been taken from the
Draft version of Brent Welch's Practical Programming in Tcl and Tk.
It contains a lot more detailed information regarding Tcl and C, Tk
and C, and integrating Tcl/Tk with C.