Indices problem in c++


why i was not getting an error

Your code is not producing any output, instead of returning an array, use a void function and simply check :
if(curr_index==N)
{
return;
}
if(ar[curr_index]==M)
{
cout<<curr_index<<" ";
}
indices(ar,N,M,curr_index+1);
You can simply use a recursive approach in your code.