Popular Posts

Saturday, July 19, 2008

STRINGS

STRINGS:

The way a group of integers can be stored in an integer array, similarly a group of characters can be stored in a character array.
Character arrays are many a times also called strings.Programmers use character arrays or strings in programming languages to manipulate text such as words and
sentences.

A string constant is alone dimensional array of characters terminated by a null('\0').
Ex:
char name[]={'k','a','m','e','s','h','\0'};

the terminating null('\0') is important,because it is the only way the functions that work with a string can know where the string ends.
In fact, a string not terminated by a '\0' is not really a string,but
merely a collection of characters.

Ex: char name[]="kamesh";
Note that, in this declaration '\0' is not necessary.c inserts the null character automatically.

No comments:

Post a Comment