The Gateway to Computer Science Excellence
0 votes
143 views
#include<iostream>
using namespace std;

int i=0;
void a()
{
i+=1;
cout<<i<< ".hello"<<endl;
a();
}

int main()
{
a();
}

For this above code the output is only upto โ†’  64891.Hello

Does this mean that that the stack can hold only 64891 recursive calls? (I am using dev c++)

in Programming by Active (3.5k points)
retagged by | 143 views
0
showing error :(
0
It runs perfectly in dev c++ .. ๐Ÿ˜ถ
0
how?? dry run code and tell me how running correctly?
0
we are calling a() infinite times and it prints.. 1.hello 2.hello 3.hello and so on
0
yes, then is it not stack overflow error??
0
ya..it is stack overflow..but output should be printed upto a certain point right?
0
upto infinity, no certain point there
0
dev gives output upto 64891.. and my question is also based on this that why upto 64891? is the stack capacity only that?
0

43169.hello

--------------------------------
Process exited after 54.19 seconds with return value 3221225725
Press any key to continue . . .

mine exited like this

1 Answer

+1 vote
I run the same code in ubuntu terminal and each time I executed the code, it shows me a different value of 'i' around 5 lakhs with a message segmentation fault (core dumped)
by (33 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,516 answers
195,578 comments
101,130 users