PPT Slide
- In C, a string is an array of characters. The array contains the characters in the string followed by an extra char (byte) containing a binary zero.
- Example: “hello” is represented by an array:
- Because strings are arrays, and because array names are basically pointers, the assignment and comparison operations manipulate pointers, and not the strings themselves.
-
char s[ ]= “hello”;
char t[ ]= s; /* s and t point to same place*/
s[1]= ‘?’;
/* s and t are now “h?llo” */
- Standard library strlib.h contains routines to copy string values, catenate them, compare them, etc.