C++ FAQ Celebrating Twenty-One Years of the C++ FAQ!!!
(Click here for a personal note from Marshall Cline.)
Section 5:
[5.8] How do I post a question about code that doesn't work correctly?

Key guidelines:

  1. Post compile'able code: avoid ellipses, such as void f() { ... }
  2. Post complete code: put in all necessary #includes and declarations of needed types and functions
  3. Post minimal code: just enough to demonstrate the problem; skip I/O and calls to libraries if possible
  4. Post one compilation unit: if possible, combine Foo.h into Foo.cpp
  5. Post the tools you used: compiler name, version number, operating system, etc
  6. Post the tool options you used: libraries, exact compiler and linker options, etc
  7. Post the exact messages you received; differentiate between compiler, linker, and runtime messages
  8. Make sure main() has a return type of int, not void!

As always, make sure your question isn't already in the FAQ. Use the subject index to check.