|
-
Feb 24th, 2002, 05:19 AM
#1
Since the compiler scans your code from top to bottom without ever looking ahead, you'll get an error when you call a function that is declared later:
Code:
int main()
{
func(4); // error: the compiler doesn't know the name "func"
return 0;
}
void func(int i)
{
// do something
}
This is where "function prototypes" come in. A function prototype looks like the normal function definition except that it has no code. It's purpose is just to tell the compiler that there indeed is such a function. The prototype for the "func" above would be:
void func(int i);
You don't need to specify a name for the parameter, so this would be legal too:
void func(int);
A header file is usually a collection of function prototypes and type definitions.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|