One habit
Never trust a C++ project that only ran once in your IDE. Build it from the terminal, run small tests, then debug with tools when it fails.
Your HackIndia repo should let another builder clone it, compile it, and check sample cases without guessing.
Compile locally
For a small project, one clear compile command is enough. Keep it in your README and test it on your own laptop before submitting.
Use warnings while building. They catch many bugs before your program runs.
Starter command
This builds one file into an executable named app. It uses a modern C++ standard and common warning flags.
g++ -std=c++17 -Wall -Wextra -pedantic -g main.cpp -o app
./appTest with files
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 5 done
mkdir -p samples
./app < samples/input1.txt > samples/output1_actual.txt
diff samples/output1_expected.txt samples/output1_actual.txtTiny test setup
For a student expense splitter, your sample data can be simple. The point is repeatability, not a huge dataset.
samples/input1.txt
3
Asha 120
Ravi 60
Imran 0
samples/output1_expected.txt
Each person should pay: 60
Asha gets 60
Imran pays 60Use gdb calmly
When your program crashes, do not add random cout lines everywhere first. Rebuild with -g, then run it inside gdb.
The backtrace shows where the program failed. The frame command lets you inspect that exact function.
g++ -std=c++17 -Wall -Wextra -pedantic -g main.cpp -o app
gdb ./app
run < samples/input1.txt
bt
frame 0
print variableNameCommon trap
Do not test only the happy case. Add cases for empty input, one item, duplicate names, large values, and invalid lines if your project accepts user text.
Also avoid hardcoded absolute paths like C:\Users\name\file.txt or /home/name/data.txt. They will break on someone else’s machine.
Do this now
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 5 done