In principle, you don't need to put in a copyright statement to own the copyright on something you have written. There are a few exceptions, such as stuff you write as part of your employment or when you explicitly transfer your copyright, but that is the general principle that copyright law is based upon.
The point of putting in the copyright statement is mostly to make it abundantly clear to the reader who own the copyright.
Another thing is that, unless there is a licence granting others those rights, the copyright holder is the only one that is permitted to copy, distribute or modify the work. And most open-source licences require that you explicitly state who owns the copyright.
So, in the end, if you happen upon something that does not have a clear copyright statement and appropriate licence, it is best to assume you can't use it. But I would not rely on others to presume the same thing.
The best way to protect your code is not to put it out in a publicly accessible place. The second best is to clearly state the copyright and licence.