1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

技術英語 > Off-by-one error / OBOE

Last updated at Posted at 2015-04-16

Code CompleteかReadable Codeででていたと思う。

1つずれてしまって使っているエラー.

sample.c
#include <stdio.h>
int idx;
double val[10] = { /* 適当な値 */ };

for(idx=1; idx<=10; idx++) {
    printf("val=%lf\n", val[idx]);
}

上記の例ではidxを0でなく1から始めてしまっている点がoff-by-one errorとなっている。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?