mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-09 00:06:47 +02:00
Add more notes to function prototype in C.
This commit is contained in:
@@ -425,13 +425,16 @@ int add_two_ints(int x1, int x2)
|
|||||||
|
|
||||||
// Must declare a 'funtion prototype' before main() when creating functions
|
// Must declare a 'funtion prototype' before main() when creating functions
|
||||||
// in file.
|
// in file.
|
||||||
int getInt(char c); // function prototype
|
void getInt(char c); // function prototype
|
||||||
int main() {
|
int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int getInt(char w) { //parameter name does not need to match function prototype
|
void getInt(char w) { //parameter name does not need to match function prototype
|
||||||
return 1;
|
;
|
||||||
}
|
}
|
||||||
|
//if function takes no parameters, do: int getInt(void); for function prototype
|
||||||
|
// and for the function declaration: int getInt(void) {}
|
||||||
|
// this is to keep compatibility with older versions of C.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Functions are call by value. So when a function is called, the arguments passed
|
Functions are call by value. So when a function is called, the arguments passed
|
||||||
|
Reference in New Issue
Block a user