I am just playing with c++ codes; why here count is printing 0, where I am expecting it to be 10, just want to count how many times the function is called itself.
Code:using namespace std;
void count_fn(int n, int *count) {
if(n==0) {
return;
}
else {
*count++;
n--;
count_fn(n, count);
}
}
int main(int argc, char *argv[])
{
int *count = new int(0);
count_fn(10, count);
cout << endl <<"Count is" <<*count << endl;
}