Gotchas
Watch out for some common unintentional mistakes that can be made in C.
We'll cover the following
There are a number of classic gotchas in C to watch out for when trying to figure out why our program is not running as expected (or not running at all). We should check for these first when debugging, they are common.
Integer math
Like Python, in C when we write mathematical expressions, we should be sure to include decimal points for all numbers (that is, unless we actually want to do integer math). This is best illustrated by the following example. What do you think the following code will print to the screen?
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy