Software engineer. Hedonist. Vegetarian. Fiancé of the amazing Cass.
Catching Elephant is a theme by Andy Taylor
In C, numbers beginning with a zero are evaluated in base 8. If there are no 8’s or 9’s in the numbers, then there will be no complaints from the compiler, only screams from the programmer when he finally discovers the nature of the problem.
int numbers[] = { 001,
010, // 8, not 10
014 }; // 12, not 14Not convinced ? Try
atoi("000010");
When being pedantic for typographical quality I use spaces rather than zeroes so I haven’t experienced this problem, but I can imagine losing hours and hours trying to figure out why atoi can’t parse padded integers.
(Source: andromeda.com)