I am trying to run this code which for some reason crashes during execution with "Segmentation fault (core dumped)" error.When i ran this in Code::Blocks debugging mode,call stack showed me a different address for pointer after after some 130000 iterations.
#include <iostream>
using namespace std;
long long counter = 0;
void test(int* ptr)
{
cout << ptr[0];
if (counter == 10000000)
return;
counter++;
test(ptr);
}
int main()
{
int arr[2];
arr[0] = 10;
arr[1] = 20;
test(&(arr[0]));
return 0;
}