8.1 Introduction
Strings are inseparable part of any small or large program. It is very unfortunate that strings have not been defined as fundamental data type in our language. Strings are handled with the help of pointer to char. However we should declare stings with the help of array of characters, e.g.
char myName[20];
Header file “string.h” contains lot of functions to work with strings.
Let us first understand how strings are stored in the machine. Let us assume that the value stored in myName as “RAJARAM”. All the seven characters will be stored in the array. Next a special character ‘\0’ will be stored. Character with ASCII value 0 is known as null character. It will signify the end of the string. Figure 8.1 depicts this case.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access