4 ms·
Similar bug: int i = 10; int *p = &i; int j = 100/i; // j==10 right? right int k = 100/*p; // k==10 right? That last line doesn't compile.
by JoeAltmaier 15y ago
Similar bug:
int i = 10;
int *p = &i;
int j = 100/i; // j==10 right? right
int k = 100/*p; // k==10 right?
That last line doesn't compile.
- reemrevnivek 15y agoUse spaces between arithmetic operators. You've already got them around the = sign. It looks much better, and prevents this problem: int i = 10; int *p = &i; int j = 100 / i; // j==10 right? right int k = 100 / *p; // k==10 right? right Also, any decent syntax highlighter would have caught the latter problem. The problem in the blog post was much more subtle, because most (all?) syntax highlighters won't catch it.