Some homeless people can feed themselves, they just can't afford rent. Therefore, you should not give money to all but only the starving and truly needy. Homeless people are a group, and work together to get through the day. Read source for further reading.
Homeless can be considered a flaw in our social/economic system. If such, giving money to homeless only temporarily fix the problem. This is unsustainable. The right thing to do is certainly to structurally fix the problem, and thus to give money to NGOs/politics that have the potential to do it.