DS Module 1_Strings
DS Module 1_Strings
Applications
Module 1
Strings
THE STRING ABSTRACT DATA TYPE
• In C, we represent strings as character arrays
terminated with the null character \0.
• Notice that we have included array bounds for the two strings.
Technically, we could have declared the arrays with the statements:
• char s[] ={"School"};
• char t[] = {"Building"};
• Using these declarations, the C compiler would have allocated just
enough space to hold each word including the null character.
• Assume that we have two strings, string and pat, where pat is a pattern to be searched for
in string. The easiest way to determine if pat is in string is to use the built-in function
if (t = strstr(string,pat))
else