Rasul Allah (sal Allahu alaihi wa sallam) said: “Whoever acts to be heard and seen, God will cause his falsity to be heard and seen.” [Bukhari, Muslim]
If B works for C but then comes to you demanding payment, wouldn't you say, "Go and ask C for your wages, it is not me that you worked for!" When you do good deeds, you either do it for Allah (subhana wa ta'ala), or for other than Allah (subhana wa ta'ala). This "other than Allah" could be people's appreciation, fame, money, power, or anything else.
In order for any action of yours to be worthy of reward in the Hereafter, it must have been done sincerely for Allah (subhana wa ta'ala), and for Allah alone. The reward/hasanaat for the deed will be decreased in proportion to the extent that other motives enter into the intention behind the good deed. Furthermore, Allah (subhana wa ta'ala) tells us in this hadith, that He will make known to the people the real reason that you are doing good deeds.
Abu Umar explained ikhlas (sincerely doing something only for Allah) in this way: “It is present when one wishes to be praised for something only by God.”
According to Dhul-Nun, one of the ulema explained the possession of ikhlas in this manner: “Whenever a man does something sincerely for God, he feels a longing to be in a cave where he will not be recognized.” This is because if only Allah (subhana wa ta'ala) knows what you did for Him, your reward will not be diminished by others' praise and your taking pride in what you have done. Always ask Allah (subhana wa ta'ala) to purify your intentions and not let your sins and shortcomings take away from your good deeds.