Cobol Tips a fairly in-depth look at how to declare simple and complex variables, as well as use various techniques for initializing them. So read on, and prepare to be amazed. Imagine, no more declaring global variables that are used only once, or even not at all. Our next variable type is the string, or character array.
C deals with strings in an extremely annoying way.
Because everything is a single character, you have to define an array of characters. This is also how you have to reference it. Character arrays in C will always be null terminated, so if you need an eight-character array you need to specify nine characters to account for the null character at the end. The only way to initialize a character array to spaces in C is to move single characters to each element of the array. The second example is really nasty and is an example of moving spaces into the unused portion of a string and getting rid of the NULL character.