Professional Documents
Culture Documents
3. It is much better to place all the function prototypes in a header file (.h extension)
Place all the function implementations in a file (preferably with the same name) but a .c
extension
Have an include guard to present multiple includsion. Include guard is typically set out as:
#ifndef FILE_NAME_H
#define FILE_NAME_H
....//the prototypes
#endif
2. When a FUNCTION or global variable is declared as static in a FILE, that function or global
variable is only known in that file.
Passing parameters
Passing parameters by value: When a parameter is passed to a function by value, the function
receives a copy of the parameter. Local changes do not affect the original value
Example
void passByValueExsmple(int a)
Call as passByValueExsmple(x)
Passing parameters by reference:
A reference is passed to the function. Changes to the variable affect the passed copy.
Eg
void passByRefExample(int *a){
*a= * +4; //use *a in the code
}
Call as passByRefExample(&x);
Enum
Enum is a user defined type that gives names to integer values. eg
the variable can be used wherever an integer could have been appropriate, eg in a switch
statement.
eg
switch (machine_state){