Isn't this"static size_t ctr=0" executed every time? and Initialized to 0 every time? Even the memory remains but the value can be re-initialized, right?
I'm not 100% sure of what I does because I only rarely use it, but when I do use it, it's when I don't want my variable to be reinitialized, and your variable indeed isn't reinitialized here. You can still use ctr = 0 in a separate statement and get your ten 1s, but like that, it will just keep on counting.
If you axe the static, then your function will print all ones.