C

C Programming Tutorial 5: Structures and Unions

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 …

C Programming Tutorial 5: Structures and Unions Read More »

C Programming Tutorial 4: Pointers and Arrays

1.0 Introduction A pointer variable holds the address of another variable. It is said to be “pointing” to that variable. For example, int *ip; defines a variable ip of type integer pointer. ip points to a variable of type integer. At the implementation level, it holds the address of a variable to type integer. The …

C Programming Tutorial 4: Pointers and Arrays Read More »

C Programming Tutorial 3: Control Flow and Functions

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. In this post, …

C Programming Tutorial 3: Control Flow and Functions Read More »

C Programming Tutorial 2: Data Types and Expressions

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. In this post, we will be looking at data types and expressions …

C Programming Tutorial 2: Data Types and Expressions Read More »

C Programming Tutorial 1 – Getting Started

1.0 Introduction C is a procedural programming language invented by Dennis Ritchie in 1972. C is, possibly, the most widely used programming language in the last fifty years. There are some unique features of C. It is a small language; so it can be easily learnt. It can be used for almost all kinds of …

C Programming Tutorial 1 – Getting Started Read More »

How to trim a string in C

The problem of removing leading and trailing whitespace characters in strings occurs in programming quite often. Here is a solution. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> void trim (char *dest, char *src); int main (int argc, char **argv) { char inbuf [1024]; char outbuf [1024]; printf (“Type a string : “); while (fgets …

How to trim a string in C Read More »

Queue implementation in C using linked list

1.0 Queue A queue is something we see often in our daily lives. People stand in a queue to get into a bus, to get food in a buffet, buy tickets from the ticket counter, etc. Queues are a fair solution of ordering people to get a resource; people are served in the chronological order …

Queue implementation in C using linked list Read More »

Gtk-WARNING **: cannot open display:

While running a GTK+ based C program under Cygwin, the following runtime error is observed, Gtk-WARNING **: cannot open display: SOLUTION Make sure that Cygwin/XServer is installed and is running. If it is not installed, download the relevant packages from Cygwin. Make sure that environment variable DISPLAY is defined in the shell's environment. If DISPLAY …

Gtk-WARNING **: cannot open display: Read More »

cygwin1.dll not found

A C program was compiled under Cygwin and run directly under Windows. The following runtime error was observed, cygwin1.dll not found SOLUTION Make sure that the environment variable, PATH, has the directory C:\gygwin\bin which contains the dll, cygwin1.dll. On Windows Vista, this can be done as follows: From Start menu, click Control Panel. Click System. …

cygwin1.dll not found Read More »