S
Seong-Kook Shin
Hi, I'm reading Steve's "C Programming FAQs" in book version,
and have two question regarding to Q11.16
... Also, a `return' from `main' cannot be expected to work if
data local to main might be needed during cleanup. (Finally
the two forms are obviously not equivalent in a recursive call
to `main').
My questions are
1. Does ANSI standard say that these two forms of
termination of program might be different? I have C99 copy, and
it says..
5.1.2.2.3 If the return type of the `main' function is a type compatible
with int, a return from the initial call to the `main' function is
equivalent to calling the `exit' function with the value returned by
`main' function returns a value of 0.
If these two forms are equivalent, from when are they equivalent?
ANSI? or C98? or C99?
2. Steve's mention to "recursive call" and C99's "initial call to the main".
I think that it is possible to call main() recursively. But I want
to make it
sure. Is it legal to call main() recursively? And if yes, can
anyone show me
practical (or concise at least) example of it?
3. Above C99 5.1.2.2.3, In "If the return type of the main is a type
compatible
..." Euh? Is it possible that main()'s return type is not compatible
with int?
I thought main should be one of these two forms:
int main(void) { ... }
int main(int argc, char *argv[]) { ... }
I'll thank you for your answers in advance.
Regards,
and have two question regarding to Q11.16
... Also, a `return' from `main' cannot be expected to work if
data local to main might be needed during cleanup. (Finally
the two forms are obviously not equivalent in a recursive call
to `main').
My questions are
1. Does ANSI standard say that these two forms of
termination of program might be different? I have C99 copy, and
it says..
5.1.2.2.3 If the return type of the `main' function is a type compatible
with int, a return from the initial call to the `main' function is
equivalent to calling the `exit' function with the value returned by
`main' function returns a value of 0.
If these two forms are equivalent, from when are they equivalent?
ANSI? or C98? or C99?
2. Steve's mention to "recursive call" and C99's "initial call to the main".
I think that it is possible to call main() recursively. But I want
to make it
sure. Is it legal to call main() recursively? And if yes, can
anyone show me
practical (or concise at least) example of it?
3. Above C99 5.1.2.2.3, In "If the return type of the main is a type
compatible
..." Euh? Is it possible that main()'s return type is not compatible
with int?
I thought main should be one of these two forms:
int main(void) { ... }
int main(int argc, char *argv[]) { ... }
I'll thank you for your answers in advance.
Regards,