A person acting out of charity or selflessness is aiming to help somebody more than they help themselves, and would take such an act even if nobody knew they did. Just recently viewing news of Hurricane Harvey, we see selfless people risking their own lives to save others, and in interviews with the saved, they don't even know the names of their rescuers. Those heroes are not getting any money or fame, or certainly do not appear to have gone out in the flood to seek camera crews.
In fiction of course you can be more certain. The test for altruism is simple: Mental satisfaction or pleasure to be gained by an act doesn't count. From the outside, if Charlie risks tangible assets to help Dave, and in all expected outcomes from Charlie's point of view (success or failure) he will be left with fewer assets after the attempt, and all Dave can do is benefit, then Charlie is an altruist. He may feel good about it if he succeeds, but that doesn't matter.
By 'assets' I mean whatever Charlie could have kept for himself but put on the line to help Dave: His time, his boat, his money, his life, his romance with Elaine. Whatever. If it looks like Charlie only has something to lose by helping Dave, and does it anyway, that is charity or selflessness. If I give a homeless man \$5 and don't speak of it to anybody, that was a charitable act by me.
On the other hand, if I help somebody with the expectation of gain, be it fame, money, or power, it is no longer charitable (even though I may help somebody), it is now commercial. George Lucas wrote Star Wars, but not out of the goodness of his heart: He expected, and received, money. Star Wars has been on balance a net positive in the world, not intended to hurt anybody and an entertainment for nearly all that watched it. But Lucas would not have done the work without the expectation of someday getting money for it. It was a gamble, but the potential for gain is what drove him to put in the time and eventually others to put in the many millions it would take to make the movie and promote it, years before a single dime of ticket sales came in.
On the third hand, if somebody does harm to somebody with the expectation of gain, that is criminal, or at least selfish, cruel, greedy, etc. So Theft, Rape, Slander, Arson, Kidnapping, Murder, Assassination, Dereliction of Duty, Bribery (given or taken), Breaking Oaths and Promises, Cheating on a spouse, Withholding knowledge of a danger or actively Lying about a danger, Deceptions in general with the potential of harm.
On the fourth hand, if somebody simply enjoys harming others, without any expectation of tangible gain, then you have reached the state of either insanity or evil. That includes those that risk something (prison, death, money or other assets) in order to harm others for their own enjoyment: Serial killers, for example.
In human eyes, this is often a matter of weighing things on a simple balance. Say we are in high school, and Frank has a crush on Karen, but Karen barely knows him. Frank happens upon Gary harassing Karen, not raping her but pawing for the fun of irritating her. Gary is a lout and a bully, but Frank steps in to protect Karen, risking being pummeled. Is Frank being selfless? He may gain Karen's gratitude, he may not. He will almost definitely be harmed by Gary. In most people's eyes, on balance Frank is a hero; he likely stands to lose more than he gains, and he stepped in out of love for Karen, whether that love is returned or not.