Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Code #include<stdio.h> int main() { int i; printf("%d \n",'\1'); printf("%d \n",'\022'); printf("%d ",'\555'); return 0; }
出力:1 18 109
このプログラムをコンパイルすると、gccコンパイラは警告を表示します'\ 555'は8進数のエスケープシーケンスが範囲外ですか?この範囲は何ですか?
C99仕様から、§6.4.4.4パラグラフ9:
8進数または16進数のエスケープシーケンスの値は、整数文字定数の場合はunsigned char型、ワイド文字定数の場合はwchar_tに対応するunsigned型の表現可能な値の範囲内でなければなりません。
上限は通常255で、これは'\377'です。これは、Cによって保証されていない8ビットのchar型を想定していますが、ほとんどの環境で安全な想定です。
'\377'