- If a function does not return a value, then its return type should be void. If a function does not use parameters, then its param-list should contain the keyword void.
- All C programs consist of one or more functions, each of which is named a subroutine that can be called by other parts of the program.
- Functions are the building blocks of C. A statement specifies an action to be performed by the program. In other words, statements are the parts of your program that actually perform operations.
- Although a C program may contain several functions, the only function that it must have is main( ). The main() function is where execution of your program begins. That is, when your program begins running, it starts executing the statements inside main(), beginning with the first statement after the opening curly brace is reached.
- The standard library in C contains functions to perform disk I/O (input / output), string manipulations, mathematical computations, and much more.
- In BASIC or Pascal, operations such as writing to a file or computing a cosine are performed using key words that are built into the language. The advantage C gains by having the as library functions is increased flexibility. Library functions can be enhanced and expanded as needed to accommodate changing circumstances. The C language itself does not need to change. As you will see, virtually all C programs you create will use functions from the C standard library.
- Another component common to most C programs is the header file. In C, information about the standard library functions is found in various files supplied with your compiler. These files all end with a .H extension. The C compiler uses the information in these files to handle the library functions properly. You add these files to your program using the #include preprocessor directive. All C compilers use as their first phase of compilation a preprocessor, which performs various manipulations on your source file before it is compiled.
- Preprocessor directives are not actually part of the C language, but rather instructions from you to the compiler. The #include directive tell the preprocessor to read in another file and include it with your program. Notice that the #include directive does not end with a semicolon. The reason for this is that #include is not a C keyword that can define a statement. Instead, it is an instruction to the C compiler itself.
- A function prototype declares a function before it is used and prior to its definition. A prototype consists of a function's name, its return type, and its parameter list.
- When the return statement is encountered, the function returns immediately. No statements after it will be executed. Thus, a return statement causes a function to return before its closing curly brace is reached.
A place where I meet the world - technology, entrepreneurship, economics, and anything that I find interesting.
Sunday, June 26, 2016
C Programming Notes
Labels:
C,
Programming
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment