Next: Exercises Up: Arrays Previous: Single and Multi-dimensional Arrays


In C Strings are defined as arrays of characters. For example, the following defines a string of 50 characters:

C has no string handling facilities built in and so the following are all illegal:

However, there is a special library of string handling routines which we will come across later (also see AppendiX ).

To print a string we use printf with a special %s control character:


NOTE: We just need to give the name of the string.

In order to allow variable length strings the 0 character is used to indicate the end of a string.

So we if we have a string, char NAME[50]; and we store the ``DAVE'' in it its contents will look like:
Fri May 20 13:40:49 BST 1994