First code.
#include <iostream>
using namespace std;
void f(int k)
{
if (k==100000)
{ cout << a << endl; return; }
f(k+1); }
int main()
{
int a = 1;
freopen("out.txt","w",stdout);
f(1);
return 0;
}
Second code.
#include <iostream>
using namespace std;
void f(int k)
{
int a = 1;
if (k==100000)
{ cout << a << endl; return; }
f(k+1); }
int main()
{
freopen("out.txt","w",stdout);
f(1);
return 0;
}
the second code gives stack over flow error .
Can anyone explain me how to modify stack memory ?