Chapter Summary

I l @ ve RuBoard

Chapter 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 this:

 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, when used with the %s specifier , can be used to read in single-word strings.

The C preprocessor searches a source code program for preprocessor directives, which begin with the # symbol, and acts upon them before the program is compiled. The #include directive causes the processor to add the contents of another file to your file at the location of the directive. The #define directive lets you establish manifest constants, that is, symbolic representations for constants. The limits.h and float. h header files use #define to define a set of constants representing various properties of integer and floating-point types. You also can use the const modify to create symbolic constants.

The printf() and scanf() functions provide versatile support for input and output. Each uses a control string containing embedded conversion specifiers, which indicate the number and type of data items to be read or printed. Also, you can use the conversion specifiers to control the appearance of the output: field widths, decimal places, and placement within a field.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net