example programs

C Programming Tutorial 5: Structures and Unions

  • by

1.0 Structures

A structure, in the C programming language, is a collection of variables for an entity. The variables are known as members of the structure and are located at consecutive memory locations. The size of the structure is the sum of sizes of the members plus any padding that might be placed by the system.… Read more

C Programming Tutorial 3: Control Flow and Functions

  • by

1.0 Introduction

A C program comprises of global data and functions. A program must have a main function and the execution starts at the first statement in the main function. A function has local data and statements. The control flow deals with the order in which statements are executed by a program.… Read more

C Programming Tutorial 2: Data Types and Expressions

  • by

1.0 Introduction

Data is an important part of a program. In fact, programs are written so that data can be captured, processed, stored and presented to the user. The success of a program depends on how well data has been organized and used.… Read more

I/O multiplexing: select, poll and epoll in Linux

1.0 I/O multiplexing

I/O multiplexing is the the ability to perform I/O operations on multiple file descriptors. Input operations like read, accept and calls for receiving messages block when there is no incoming data. So, if an input call is made and it blocks, we may miss data from other file descriptors.… Read more

How to create a temporary file in Linux

  • by

1.0 Temporary Files

Quite often, we need temporary files in our programs. Some intermediate data needs to be stored and the file can be discarded when the process terminates. There are functions and command to create temporary files in Linux. The mkstemp function creates a temporary file and returns a file descriptor.… Read more

Interprocess Communication using Unix Domain Sockets

  • by

1.0 Unix Domain Sockets

A socket is a communication endpoint at a host computer. The socket API provides calls for communication between processes. The socket system call is,

int socket (int domain, int type, int protocol);

The first parameter to the socket system call is the domain.… Read more