0.7 — When it does not work
Something went wrong? That is normal. Here are the most common problems for brand-new programs.
"It flashes and closes"#
On Windows, the window may open and close too fast to read. Run it with Start Without Debugging (Ctrl + F5) in Visual Studio. The window will wait for you.
"expected ';'"#
You forgot a semicolon. The error often points at the line after the real mistake. Look at the end of the line before it too.
"'cout' was not declared"#
Check two things:
- Do you have
#include <iostream>at the top? - Did you write
std::cout, not justcout?
"undefined reference to main"#
Your program has no main, or it is spelled wrong. It must be main, all lowercase.
Weird quote marks#
If you copy code from a word processor or chat app, quotes can turn into fancy quotes: “ ”. C++ only understands straight quotes ". Retype them.
Fix the first error message first. One mistake can cause many errors further down. Fix the first one, compile again, and many others often disappear.
Tip: press ← / → to move between lessons, / to search.