What motivates people to answer questions in Stack Overflow?
I have spent some time on Stack Overflow mostly answering questions, but also asking some. While I was doing it I've noticed a clear pattern. A lot, if not most of the questions come from newbies that just started to learn programming. For C, more than 50% of such questions are about corrupting the heap by not allocating memory.
I was surprised to see that in each particular case highly skilled developers took their time to explain what the problem is. They haven't just answered "you are writing to
a, but you haven't allocated space for it". Normally they have actually written a lengthy answer.
I cannot understand their motivation. Why do they do it?
(I can understand why people write Wikipedia articles. The situation with Wikipedia is however completely different. People write content only once. And do not repeat explaining each newbie that memory should be allocated, and that's why they are much more efficient.)