Summary
A string is a series of characters treated as a unit. In C, strings are represented by a series of characters terminated by the null character, which is the character whose ASCII code is 0. Strings can be stored in character arrays. An array is a series of items, or elements, all of the same type. To declare an array called name and having 30 elements of type char, do the following:
char name[30];
Be sure to allot a number of elements sufficient to hold the entire string, including the null character.
String constants are represented by enclosing the string in double quotes: "This is an example of a string".
The strlen() function can be used to find the length of a string (not counting the terminating null character). The scanf() function, ...
Get C Primer Plus, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.