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 through the GIT web interface. Good examples packages are:

Rather basic usage of the foreign interface.
Both simple and more complicated code to access OS primitives.
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 and the code uses a different mechanism to register foreign predicates.

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