【初心者歓迎】C/C++室 Ver.44【環境依存OK】
■ このスレッドは過去ログ倉庫に格納されています
0328デフォルトの名無しさん
2007/11/15(木) 01:59:11配列要素数を超えたところを指すようにポインタに足し算すると未定義動作になる。
C99 6.5.6 p8 より( C++ では 5.7 p5 に同じ文面がある)
> If both the pointer operand and the result point to elements of the same array object, or one past the last element
> of the array object, the evaluation shall not produce an overflow; otherwise, the behavior is undefined.
この場合だと要素数 2 の char 配列とみなせるから、 2 までは大丈夫で 3 以上でアウトね。
■ このスレッドは過去ログ倉庫に格納されています