mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Edit note on function prototypes.
This commit is contained in:
parent
7c559d57a8
commit
35909645f2
@ -41,6 +41,10 @@ enum days {SUN = 1, MON, TUE, WED, THU, FRI, SAT};
|
|||||||
void function_1();
|
void function_1();
|
||||||
void function_2();
|
void function_2();
|
||||||
|
|
||||||
|
// Must declare a 'function prototype' before main() when functions occur after
|
||||||
|
// your main() function.
|
||||||
|
int add_two_ints(int x1, int x2); // function prototype
|
||||||
|
|
||||||
// Your program's entry point is a function called
|
// Your program's entry point is a function called
|
||||||
// main with an integer return type.
|
// main with an integer return type.
|
||||||
int main() {
|
int main() {
|
||||||
@ -410,15 +414,6 @@ int add_two_ints(int x1, int x2)
|
|||||||
return x1 + x2; // Use return to return a value
|
return x1 + x2; // Use return to return a value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must declare a 'function prototype' before main() when creating functions
|
|
||||||
void getInt(char c); // function prototype
|
|
||||||
int main() { // main function
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void getInt(char w) { //parameter name does not need to match function prototype
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if function takes no parameters, do:
|
//if function takes no parameters, do:
|
||||||
int getInt(void); for function prototype
|
int getInt(void); for function prototype
|
||||||
// and for the function declaration:
|
// and for the function declaration:
|
||||||
|
Loading…
Reference in New Issue
Block a user