A single downvote is really nothing to freak out about. If you start attracting several downvotes on the same question, then you will have a reason to take stock.
There are many reasons someone could have downvoted your question. It looks to me like you have posted a whole lot of code for something that is actually a rather simple issue, and would therefore be easy to demonstrate with only a few lines. That's a common reason for a downvote. So is someone feeling that your question is "not interesting" and "not likely to be helpful for others in the future". Voting is how we rank content. Although your question is useful to you, and acceptable for the format, is it not likely to be widely considered interesting and helpful by other followers of the c tag.
There is also a fairly high expectation that you will conduct some research and try to solve a problem yourself. Being completely unaware of the existence of "undefined behavior" is a sign that you probably didn't do enough background research before posting the question. If nothing else, this should have been mentioned by your C book. If it doesn't talk about undefined behavior anywhere, you should consider getting a different book.
Note that it is rarely useful for the first line of a question to be an announcement that you are a "newbie". If that is not obvious from the question itself, we don't really need to know. It is "chatty" and will probably just cast the rest of the content in a less flattering light than if it stood on its own merit.