Why is count(variable)not increasing?

ques:https://hack.codingblocks.com/app/contests/1289/340/problem
code:https://ide.codingblocks.com/s/268024

cnt is showing 0 only

It is due to you not being able to do pointer manipulation properly. There is a link on stack overflow which explains this beautifully, I am sharing that. If still not able to understand, ask anytime.

@leoking i understood what the article was trying to say but what change should i make.

@leoking I even made the variable global but still the value is same. https://ide.codingblocks.com/s/268839

You are passing the pointer by value. pass it by reference . It is creating a new pointer but this new pointers address is different.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like