Don't think OP merits all the negative comments on this thread. She was just trying to do something good, albeit in a random way. If she had stopped to ask what he wanted, she would have probably have got into the I want money debate, which she didn't want. And I don't think she is boasting about what she has done, more the feeling the rejection has caused her.
Homelessness is a complex issue. Nobody disputes that homeless people have feelings and preferences too, but am guessing OP prefers to give food so money is not spent on drugs or drink. (OK, that involves a value judgment too, but that's OP's, and not an unreasonable one, to make)
Should one expect gratitude? The correct answer, is not. However, I think it is only natural to want to feel appreciated when one puts oneself out. If you'd bought a colleague a sandwich and cake, you'd expect them to say thanks. And I don't think it's unreasonable to expect the homeless man to say thanks either - true there may be a myriad of reasons why he doesn't feel thankful, but from OP's perspective, I think it a reasonable expectation. To argue otherwise, that normal rules of social intercourse and politeness don't apply, is, in a way, defining him by his homeless status in the same way that some posters accuse the OP of by assuming he would be grateful for food by virtue of his homelessness.
Bottom line is OP (who meant well) feels she has had a good deed thrown back in her face. That feeling is not unreasonable.
The homeless man may not be homeless, he may be scamming, he could have mental health issues. He could just want money to spend on drink, drugs or whatever. He could (reasonably) be really fed up and act ungraciously in declining food he doesn't want, or he could just dislike what he sees as patronage. He is, like all of us, at the end of the day, human and imperfect.
Give money instead if you can accept that he would spend it as he wants. Or take the time to ask what he would like, or just whether he'd like anything. Or decide to give something to a charity that works with the homeless. They're all better than what a lot of us would have done, which is just walk on by.
YANBU. You tried to do something you thought was good. And it didn't work out. Disappointment is natural.