This question came up in another thread without a concrete answer.
Here is an example of what I'm talking about:
I realize that invoking main() is unnecessary, because such information can be encoded into the return value. However I was wondering if this method has negative side effects.
Thanks,
--Mark
Here is an example of what I'm talking about:
Code:
#include <stdio.h>
int test (int subject);
int main (void) {
int num;
do{
printf("Guess a number between 1 and 10 (inclusive)\n");
scanf("%d",&num);
}
while(num<1||num>10);
test(num);
return 0;
}
int test (int subject){
if(subject==7)
printf("Yay! You guessed it!\n");
else{
printf("Sorry, try again\n");
main();
}
return 0;
}
I realize that invoking main() is unnecessary, because such information can be encoded into the return value. However I was wondering if this method has negative side effects.
Thanks,
--Mark