Quote:My code doesn't show any error. My output, however, is wrong in the last part
You really need to pay attention and understand a few things.
- When the compiler find errors, it just means that your program do not conform to the language syntax and have some "spelling" errors.
- No compiler error, does not imply that the program is doing what it is supposed to do. "The cat is flying" is correct English, but also nonsense.
Quote:I tried gdb. I couldn't conclude any clear error yet
The debugger don't find errors in your program, it just show you what the program is doing, it is your task to compare with what is should do and spot mismatches.