Previous topic |
Next topic |
Contents |
Glossary |
Contact z/OS |
PDF
More information about the C++ language Application programming on z/OS |
|
C supports numerous data types, including characters, integers, floating-point numbers and pointers—each in a variety of forms. In addition, C supports arrays, structures (records), unions, and enumerations. The C library contains functions for input and output, mathematics, exception handling, string and character manipulation, dynamic memory management, as well as date and time manipulation. Use of this library helps to maintain program portability, because the underlying implementation details for the various operations need not concern the programmer. In the following paragraphs we refer to the C and C++ languages collectively as C. Source programs A C source program is a collection of one or more directives, declarations, and statements contained in one or more source files.
A function definition precedes the function body. The function body is a compound statement that can contain declarations and statements that define what the function does. The function definition declares the function name, its parameters, and the data type of the value it returns. The order and scope of declarations affect how you can use variables and functions in statements. In particular, an identifier can be used only after it is declared. A program must contain at least one function definition. If the program contains only one function definition, the function must be called main. If the program contains more than one function definition, only one of the functions can be called main. The main function is the first function called when a program is run. C source files A C source file is the collection of text files that contains all of a C source program. It can include any of the functions that the program needs. To create an executable object module, you compile the source files individually and then link them as one program. With the #include directive, you can combine source files into larger source files. A source file contains any combination of directives, declarations, and definitions. You can split items such as function definitions and large data structures between text files, but you cannot split them between compiled files. Before the source file is compiled, the preprocessor filters out preprocessor directives that may change the files. As a result of the preprocessing stage, preprocessor directives are completed, macros are expanded, and a source file is created containing C statements, completed directives, declarations, and definitions. It is sometimes useful to place variable definitions in one source file and declare references to those variables in any source files that use them. This procedure makes definitions easy to find and change, if necessary. You can also organize constants and macros into separate files and include them into source files as required. Directives in a source file apply to that source file and its included files only. Each directive applies only to the part of the file following the directive. Data types The C data types are:
From these types, you can derive the following:
The void type The void data type always represents an empty set of values. The keyword for this type is void. When a function does not return a value, you should use void as the type specifier in the function definition and declaration. The only object that can be declared with the type specifier void is a pointer. |
Copyright IBM Corporation 1990, 2010
|