1. Write C++ that does not break
5 min
Why this matters
In C++, your code can compile and still be unsafe. It may pass your sample test, then crash on a judge, a friend’s laptop, or during a demo.
This lesson is about avoiding the common break points first: bad input handling, out-of-range access, uninitialised values, and integer surprises.
One rule
Do not trust memory, input, or indexes by default. Check sizes, initialise values, and make invalid states hard to reach.
Safe C++ is not fancy C++. It is boring code that behaves the same way every time you run it.
Write safer basics
Do each one yourself, then tap it to tick it off. The ticks are only a checklist for you: they are not marked or scored.
0 of 6 done
Silent wrong code
A common beginner mistake is assuming the input is always perfect. In a project repo, your sample data may be clean, but users can type empty input, text instead of numbers, or a negative value.