C Tutorials

21. Using free() Function in C

By: Daniel Malcolm : 2007-10-03

Description: When you allocate memory with either malloc() or calloc(), it is taken from the dynamic memory pool that is available to your program. This pool is sometimes called the heap, and it is finite. When your program finishes using a particular block of dynamically allocated memory, you should deallocate, or free, the memory to make it available for future use.


22. Using memset(), memcpy(), and memmove() in C

By: Emiley J : 2007-10-03

Description: Use memset() to initialize a block of memory to a specified value. Because this function can use only a type char as the initialization value, it is not useful for working with blocks of data types other than type char, except when you want to initialize to 0. In other words, it wouldn't be efficient to use memset() to initialize an array of type int to the value 99, but you could initialize all array elements to the value 0. memset() will be demonstrated in program below.


23. Using Shift Operators in C

By: Fazal : 2007-10-03

Description: Two shift operators shift the bits in an integer variable by a specified number of positions. The << operator shifts bits to the left, and the >> operator shifts bits to the right. The syntax for these binary operators is


24. Bitwise Logical Operators in C

By: Grenfel : 2007-10-03

Description: Three bitwise logical operators are used to manipulate individual bits in an integer data type, as shown in Table below. These operators have names similar to the TRUE/FALSE logical operators, but their operations differ.


25. Trigonometric, Hyperbolic, Exponential and Logarithmic Functions in C

By: Henry : 2007-10-03

Description: The following listing contains a single program that demonstrates several of the Math functions. However if you need to refer to other functions then you may look at the tables below.


26. assert() Function Example program in C

By: Jagan : 2007-10-03

Description: How do you use assert()? It is most frequently used to track down program bugs (which are distinct from compilation errors). A bug doesn't prevent a program from compiling, but it causes it to give incorrect results or to run improperly (locking up, for example). For instance, a financial-analysis program you're writing might occasionally give incorrect answers. You suspect that the problem is caused by the variable interest_rate taking on a negative value, which should never happen. To check this, place the statement


27. ERRNO.H Header File in C

By: Kamini : 2007-10-03

Description: The header file ERRNO.H defines several macros used to define and document runtime errors. These macros are used in conjunction with the perror() function.


28. perror() Function - example program in C

By: Lakshmi : 2007-10-03

Description: The perror() function is another of C's error-handling tools. When called, perror() displays a message on stderr describing the most recent error that occurred during a library function call or system call. The prototype, in STDIO.H, is


29. Using qsort() and bsearch() with strings - example program in C

By: Manoj Kumar : 2007-10-03

Description: This program makes use of an array of pointers to strings.You can "sort" the strings by sorting the array of pointers. However, this method requires a modification in the comparison function. This function is passed pointers to the two items in the array that are compared. However, you want the array of pointers sorted based not on the values of the pointers themselves but on the values of the strings they point to.


30. Using the qsort() and bsearch() functions with values - example program in C

By: Manoj Kumar : 2007-10-03

Description: This program lets you enter up to MAX values (20 in this case). It sorts the values and prints them in order. Then it lets you enter a value to search for in the array. A printed message states the search's status.