Did you know ... Search Documentation:
Where do I find examples mixing C and Prolog?

The best source of examples are the sources of the packages. They vary from very simple to highly complicated. You can examine the packages at GitHub. Good examples packages are:

  • nlp
    Rather basic usage of the foreign interface.
  • clib
    Both simple and more complicated code to access OS primitives.
  • zlib
    Extensive example of using the stream interface to define IO filters.

You may also want to look at the Prolog source itself. Many of the foreign predicates use the public interface. Some use more low-level primitives.

See also
- Please also check out the C++ interface