Programming: C Examples

If you are new to C, please read a note on standards before continuing.

Fundamental

This section shows examples of basic C syntax and usage, including fundamental areas such as console and file input/output, arrays and pointers, functions, and structures. It also covers some of the more esoteric areas such as pointers to functions, and functions with variable numbers of arguments.

Some complete sample applications are also given, as a demonstration.

Mathematical

This section shows algorithms to solve a variety of mathematical problems.

Utilities

This section shows some more complex and complete utilities written with C. Concepts such as string handling, expression parsing and modifying the program's behaviour with command line arguments are explored.

CGI

This section shows the fundamentals of CGI programming. It examines issues such as getting and sending data from/to the server, parsing URL-encoded input, and getting around the stateless nature of HTTP using hidden form fields and cookies.

Financial

This section shows some financial applications.

Games & Puzzles

This section shows some examples of algorithms useful to solve popular puzzles, and providing an "intelligent" computer opponent.

Xlib

This section shows some basic Xlib examples. Xlib is the lowest level C interface to programming for the X window system, the standard UNIX graphical user interface.

Microsoft Windows

This section explains the basics of using the Win32 API to program for the Microsoft Windows operating system.

ncurses

This section shows the basics of using the ncurses library. ncurses is a "CRT screen handling and optimisation package" In English, it provides screen, window and terminal input operations. ANSI C provides no mechanisms for accurately manipulating terminal I/O (e.g. clearing the screen, getting a single character from the user, positioning text at a certain screen location, changing colours). ncurses provides the resources to do these things. It is a UNIX library, but has also been ported to other platforms, including DOS. A version of ncurses is available with the DJGPP DOS compiler (see the links page).

Berkeley Sockets API & TCP/IP

This section shows the basics of using the Berkeley Sockets API for network programming, in particular using TCP/IP, looking at issues such as creating and using sockets, and non-blocking IO.

© Copyright Paul Griffiths 2007

Visit Wales!Valid XHTML 1.0!Valid CSS2!