I plan on answering a question with some source code on StackOverflow, but I have formulated my answer using some source code I found elsewhere — it was an answer to another question.

I planned on:

  • Adding comments in the code linking to the question, and mentioning the original author, both at the function and function prototype (in C).
  • Stating in my answer, that it included code from an answer to another question.

Does StackOverflow have any policies about using others' answers in your answers? Do I need to get the author's consent to re-use his code snippet as part of my larger source code answer? Does he make it public domain by posting it in the first place?

I tried the FAQ and searching this meta site, I couldn't find anything directly on topic.

FYI The reason why I don't want to simply "reference" his answer is because I would prefer my answer to simply be pasted into a text file and compiled.


What you plan to do sounds fine.

The general etiquette is that quoting is okay, as long as proper attribution is added.

Because everything published on SO is licensed under the CC-Wiki license, re-using other answers with attribution is also okay legally. The license also permits you to adapt the work.

However, make sure your answer really is a meaningful contribution. If the question is identical with the other question from whose answers you want to copy the code from, it should be closed as a duplicate instead.

As far as I know, there is no official guideline on plagiarism. I asked a question related to that here: Plagiarism should be addressed specifically in the FAQ

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .