Friday, July 23, 2004

Not NULL Terminating strings in C

In 'C' programming language, a string is nothing but a NULL terminated character array (char * or char []). Functions dealing with strings (including standard library functions, such as strlen) iterate over the characters till they reach the NULL character. Absence of terminating NULL character will cause them to process beyond the end of the string and even the array itself and cause segmentation fault.

Many of the standard C library functions, such as strdup, strcat, return NULL terminated strings. But some, such as strncpy, sometimes do not.

Thursday, July 22, 2004

Common Programming mistakes are simple

Most common programming mistakes are surprisingly simple. Following posts will list some of them.