Character String Arrays and Initialization
When you define a character string array, you must let the compiler know how much space is needed. One way is to specify an array size large enough to hold the string. The following declaration initializes the array m1 to the characters of the indicated string:
const char m1[40] = "Just limit yourself to one line's worth.";
The const indicates the intent to not alter this string.
This form of initialization is short for the standard array initialization form:
const char m1[] = { 'J', 'u', 's', 't', ' ', 'l', 'i', 'm', 'i','t', ' ', 'y', 'o', 'u', 'r', 's', 'e', 'l', 'f', ' ', 't', 'o', ' ', 'o', 'n', 'e', ' ', 'l', 'i', 'n', 'e', '\", 's', ' ', 'w', 'o', 'r', 't', 'h', '.', '\O' } ;
Note the closing ...
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.