When you ask programmers how to do something, they're going to tell you what they think is the best way to do it. This is particularly true of knowledgeable, experienced programmers, the ones that frequently roam the halls of Stack Overflow and likely the very reason you chose to ask your question there in the first place. You've asked them to share their knowledge, and that's exactly what they're doing.
It's not merely an arrogance thing. They have learned through experience that doing things the wrong way is a source of bugs, and it is one that is quite easy to avoid. There is a reason they are called "best practices": because they really are the best way to do things in 99% of cases. Worse, even if we ignore all of the other problems and address only the issue you asked about, we know that you'll be back in a few minutes, hours, or days asking another question trying to solve a problem that could have been foreseen and averted long ago. (Related reading: X-Y problems; all too common here.)
Having a low reputation score next to your name tends to bring this out even more. It isn't because we think you're stupid or "uncool", of course. We just assume that you're relatively new and may not know the right way to do things yet. None of us did at first. We give you credit for being willing to learn, and we're willing to teach. Worse, in the C and C++ tags, we assume that you may be learning from one of the many outdated or downright wrong books out there on those languages. Before I clicked through to see the actual question, I figured it would be another one of those cases where you'd asked a question with the C++ tag but used a bunch of C functions, like
printf. Lots of so-called "C++" books still teach the C way to do things, and it raises the ire and suspicions of experienced C++ programmers reading your question.
Of course, it's not just isolated to a low reputation score. Experts are equal-opportunity nitpickers. I have some 80k in reputation right now, but if I posted a question that included a bunch of code doing things counter to intuition and/or best practices, I would get plenty of comments from well-meaning people telling me of a better way to do it. Some of them would be snarky (comes with the territory), some would simply be inquisitive, and others would be genuine, honest-to-goodness constructive suggestions. All, of course, would be useful.
The truth is, you need to learn to appreciate and embrace this aspect of an expert Q&A site. You might not know it at the time, but the advice people can give you is invaluable. We don't explicitly do code reviews here (you need to have an actual problem to be solved), but then again we do. And you can learn so much from it. Like I said way up there, it's got to be at least part of the reason you brought your problem to Stack Overflow in the first place.
But okay, blah blah blah, you know all of that already. Whether you look like a n00b or not, you've got a darn good reason for doing things the way you're doing them and you don't need to be told that it lacks the blessing of the C gods. The simple solution is to explain yourself. Ask the question, show the code, and then simply observe that you know you're doing some "weird" things, but you have a reason for them. Tell us why you're doing it and tell us what your constraints are. Not only will that keep us from telling you things you don't want to know, it will also make the answers better by avoiding incorrect assumptions and the use of unacceptable functions. Improving your question through editing, as you've done, is exactly what you should be doing.
Still, don't be too quick to put your fingers in your ears and tune out the suggestions of these folks. They really do mean well, and the truth is that they're right most of the time. Even if you end up ignoring their advice, it doesn't hurt to hear it. And it certainly doesn't hurt for it to be there when someone else with the same problem (and without the same constraints) happens across your question looking for a solution to the same problem.
Most of this stuff happens in comments. That's totally acceptable; don't let it bother you too much. Good answers also tend to explain and give advice on more than just the narrowly-focused problem you've asked about. Also completely acceptable, like a two-for-one special.
The only thing that's a problem are answers that fundamentally do not contain an answer your question. Downvote those. Leave a comment to that end, if you like. If your question was clear and these people chose to ignore it, that's their fault. They know what the answer box is for.