C Tutorials

71. Address Arithmetic and pointers in C

By: Reema sen : 2007-09-22

Description: If p is a pointer to some element of an array, then p++ increments p to point to the next element, and p+=i increments it to point i elements beyond where it currently does. These and similar constructions are the simples forms of pointer or address arithmetic.


72. Character Pointers and Functions in C

By: Sam Chen : 2007-09-22

Description: A string constant, written as "I am a string" is an array of characters. In the internal representation, the array is terminated with the null character '\0' so that programs can find the end. The length in storage is thus one more than the number of characters between the double quotes.


73. Pointer Arrays and Pointers to Pointers in C

By: Tamil Selvan : 2007-09-22

Description: Since pointers are variables themselves, they can be stored in arrays just as other variables can. Let us illustrate by writing a program that will sort a set of text lines into alphabetic order, a stripped-down version of the UNIX program sort.


74. Multi-dimensional Arrays in C (Explained using date conversion program)

By: Abinaya : 2007-09-22

Description: C provides rectangular multi-dimensional arrays, although in practice they are much less used than arrays of pointers. In this section, we will show some of their properties.


75. Initialization of Pointer Arrays in C

By: Baski : 2007-09-22

Description: Consider the problem of writing a function month_name(n), which returns a pointer to a character string containing the name of the n-th month. This is an ideal application for an internal static array. month_name contains a private array of character strings, and returns a pointer to the proper one when called. This section shows how that array of names is initialized.


76. Pointers vs. Multi-dimensional Arrays in C

By: Charles : 2007-09-22

Description: Newcomers to C are sometimes confused about the difference between a two-dimensional array and an array of pointers. int a[10][20]; vs int *b[10];


77. Command-line Arguments in C

By: Daniel Malcolm : 2007-09-22

Description: In environments that support C, there is a way to pass command-line arguments or parameters to a program when it begins executing. When main is called, it is called with two arguments. The first (conventionally called argc, for argument count) is the number of command-line arguments the program was invoked with; the second (argv, for argument vector) is a pointer to an array of character strings that contain the arguments, one per string. We customarily use multiple levels of pointers to manipulate these character strings.


78. else if statement in C

By: Henry : 2007-09-20

Description: This sequence of if statements is the most general way of writing a multi-way decision. The expressions are evaluated in order; if an expression is true, the statement associated with it is executed, and this terminates the whole chain. As always, the code for each statement is either a single statement, or a group of them in braces.


79. goto and labels in C

By: Norman Chap : 2007-09-20

Description: C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto statement is never necessary, and in practice it is almost always easy to write code without it.


80. break and continue loops in C

By: Lakshmi : 2007-09-20

Description: It is sometimes convenient to be able to exit from a loop other than by testing at the top or bottom. The break statement provides an early exit from for, while, and do, just as from switch. A break causes the innermost enclosing loop or switch to be exited immediately.