I recently answered a question here: bubble sort a character array in alphabetic order in c
I felt that due to the nature of the code, the best way to help the OP learn would be to provide him with improved code. I don't typically do that, but in this case I felt it was appropriate so that his own code could be used as an example of how to incrementally fix and improve code for style + clarity.
However after I posted the answer and it was accepted, I saw in the comments that the question was actually for homework! So I inadvertently provided the answer to a homework question.
What is the best course of action to take in this situation? Should I leave the answer up so that it benefits others? Should I delete the answer (even though the OP has seen it) because it gives away a homework answer?
Can we have a system in place that clearly prompts users to indicate if a question is homework? I feel as though I've been duped into spoon-feeding the OP an answer to his homework.