Re: What will happen if main called in side main function?




"Ravi" <ravi.wireless@xxxxxxxxx> wrote in message
news:1143826569.981525.100270@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
But i have read that C can have only one main function, so is this
valid?

Please always include the context of your message.

int main() {
main();
return 0;
}

There is only one instance of main() defined. It just happens to recursively
call itself.
Forever.

This, on the other hand, will eventually stop:

int num = 10;
int main() {
if ( --num > 0 ) {
main();
}
return 0;
}
--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


.



Relevant Pages

  • Re: Strtol vs sscanf
    ... > the malloc error's before exiting which variables failed to get ... > int main{ ... Boeing Associate Technical Fellow ...
    (comp.lang.c)
  • Re: Linked list w/ structure
    ... I have no problem when first_name in the structure is an int. ... you define first_name as a character array here. ... Language: C ... Boeing Associate Technical Fellow ...
    (comp.lang.c)
  • NULL argument to strcmp
    ... What does the standard say about a NULL value being passed to strcmp? ... int n = strcmp; ... Boeing Associate Technical Fellow ...
    (comp.lang.c)
  • Re: how many ways to convert a integer to a string
    ... int i = 333; ... char* s; ... Boeing Associate Technical Fellow ... Technical Architect, Software Reuse Project ...
    (comp.lang.c)
  • Re: Return value of system
    ... > int main ... Boeing Associate Technical Fellow ... Technical Architect, Software Reuse Project ...
    (comp.lang.c)