The first and only time I've offered to buy a homeless person food he was incredibly cheeky. I had expected a sandwich and a drink but he asked for the bumper pack of three, two bottles of Lucozade, crisps, a chocolate bar and also asked if I could buy him fags. I don't bother now.
I used to work in a shop at the bottom of a block of flats, there were a few "homeless" men who lived in the flats, they used to go begging and bring the change to me to change it up into notes for them. They used to make an awful lot of money. I'm afraid it's all rather clouded my opinion of beggars
So you've had a distasteful experience with a few (or even just one!) members of an extremely diverse population about which you understand nearly nothing, and use that to justify a complete lack of generosity forevermore? That makes no sense. More likely you are simply stingy, but you know deep down you know that's not a very nice character trait, so you rely on these fictions so you can look yourself in the mirror. That's fine if you can fool yourself but I hope you don't say these things to your friends because nobody else would buy it.
When I see someone obviously in need, it doesn't matter whether they fit into my definition of "deserving." I accept (and am so thankful) that I could never understand what that person has gone through. I just know that this person's best option in life is to be without comfort, cleanliness, or dignity. If I can offer a small amount of respite from that, in whatever form that might take, I do. If you choose not to, or if you choose to limit your aid to things that meet your personal approval, that's your business.
I don't fault OP for how she approached the man she encountered, but I do fault her for being offended at his response. You just can't fathom what another person's mental or physical health or life experiences might be. Unless you walk a mile in their shoes it's simply ignorant to judge their behavior. As other posters have said, the reason for giving should not be in exchange for some display of beggarly gratitude.