Skip to the task
Layout
Back to classic view

You are looking at lesson 1. Your place is still lesson 4, task 1: Style.

READTask 14 of 21 · step 6: Common mistakes

Common mistakes

Six mistakes almost everyone makes in the first week. When something doesn't work, check this list first.

Almost everyone makes these mistakes in the first week. When the program does not build, or prints something you didn't expect, check this list first.

Common mistakes
  • Missing ;. error: expected ';' before ...: the semicolon is missing where the ^ points, usually at the end of a line.
  • Main instead of main. C tells capital and small letters apart. The code compiles, but the linker cannot find where the program starts: undefined reference to 'WinMain' (Windows) or undefined reference to 'main' (Linux, GitHub CI).
  • Forgot #include <stdio.h>. implicit declaration of function 'printf', and on the next line the compiler itself writes: include '<stdio.h>'.
  • \n in a path. "C:\new" gives no error: \n becomes a new line. In a path always write \\.
  • A single %. printf("100%") does not work, you need 100%%.
  • The new program is not in the list next to ▶. You created practice/NN/CMakeLists.txt, but CLion hasn't seen it yet: File → Reload CMake Project.

Extra: Lithuanian letters in the Run window

Optional. The course programs print English only, without Lithuanian letters; only topic 9 and practice test 2 use them on purpose, and show this setting again there. If your own program prints, say, Pažymys and the Run window shows Pažymys, the program writes UTF-8 but the window reads another encoding: Settings → Editor → General → Console → Default Encoding: UTF-8.