Printing the stack trace in C

Hi,
does anyone know how or if it is possible to print the stack trace of a C programme when an error occurs ?

I have a print_error() function that prints the appropriate error message when a programme encounters an error, and I’m trying to add some functionality to it… like printing the stack trace.

Anyone got any ideas / advice ?

thx