1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-01-17 21:49:22 +01:00

Add function prototype to C.

This commit is contained in:
Levi Bostian 2013-08-31 16:51:35 -05:00
parent dfd8afb496
commit 79fdd62c6b

View File

@ -422,6 +422,16 @@ int add_two_ints(int x1, int x2)
return x1 + x2; // Use return to return a value
}
// Must declare a 'funtion prototype' before main() when creating functions
// in file.
int getInt(char c); // function prototype
int main() {
return 0;
}
int getInt(char w) { //parameter name does not need to match function prototype
return 1;
}
/*
Functions are pass-by-value, but you can make your own references
with pointers so functions can mutate their values.