# Is there a limit on recursion of main function in C/C++, how many times main function can call itself?

+1 vote
372 views
Is there a limit on recursion of main function in C/C++, how many times main function can call itself?
posted Mar 8, 2016

+1 vote

Whenever we define a recursive function,we also define a stopping criteria when it stops to call itself.so there is no limit on calling a recursive function but it has stopping criteria.
and recursion about main function, it cannot be called as it is illegal to call main function inside main because it goes to infinite loop. like main ->main->main->but after that it will again call main function and never reach to stopping criteria so it will restart the program again and again.

Similar Questions

Can we consider "a car a man a maraca" as palindrome string?
Are they really a palindrome?

I need to write a function to flat nested lists as this one:

[[1,2,3],4,5,[6,[7,8]]]

To the result:

[1,2,3,4,5,6,7,8]

So I searched for example code and I found this one that uses recursion (that I don't understand):

def flatten(l):
ret = []
for i in l:
if isinstance(i, list) or isinstance(i, tuple):
ret.extend(flatten(i)) #How is flatten(i) evaluated?
else:
ret.append(i)
return ret

So I know what recursion is, but I don't know how is

flatten(i)

evaluated, what value does it returns?