I don't want to tell you outright - I could easily - but you won't learn anything that way. This isn't difficult so take a break, have a cup of coffee, get "this is impossible I can't do it" out of your head and try again.
Do you at least know what value pos should have? Why?
For example, should it be 27, or three million, or -pi, -273.16, any other value?
If you know what value pos should have, can you think of a way to make it have that value?
If you're completely stuck on this point, have a look at how you made len have the value 1, just after "if(n==pos)" and conditional on that, of course.
Having worked out how to make pos have the desired value, where should you place the statement that achieves that? If you're stepping through it in the debugger, watching pos, then as soon as you notice its value is "wrong" could be a good place to put it (i.e. just before the statement where it's wrong).