| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Sub |
-=> Rene Mercure wrote to All <=-
RM> The biggest STOP is that I can't refer to a part that is not before
RM> the one I'm presently
This is what prototypes are for (basically). (If you're familiar with
Pascal, they're similar to forward declarations.) Essentially, a prototype
is the function header, by itself, ending in a semicolon:
void foo(void); /* Prototype of foo() */
void bar(void)
{
foo();
}
void foo(void) /* Implementation of foo() */
{
printf("Foo!\n");
}
You can also omit the parameter variable names (but not their types) from
a function prototype. E.g.:
int mult(int, int); /* Takes two ints, don't need their names */
...
int mult(int a, int b) /* Name them here */
{
return a * b;
}
However, if you choose to name them in the prototype, that's OK too.
Put prototypes for all your functions at the beginning of your source
code, or in a separate #include'd header file, and you can call any
function from any other.
By the way, you SHOULD be able to call forward even without doing this;
the compiler should merely generate a warning about "implicit declaration
of function" -- but the resulting program might not always work correctly
if you do that. It's better to use prototypes.
... Now is the time on Sprockets when we dance!
---
* Origin: * My Place BBS * Bowie, Md USA * V.34 * (301)805-1602 * (1:109/570)SEEN-BY: 396/1 622/419 632/371 633/260 267 270 371 634/397 635/506 728 SEEN-BY: 639/252 670/213 218 @PATH: 109/8 13/25 270/101 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.