Search code examples
cescapingoctal

what is the range of octal escape sequence in c?


Code
#include<stdio.h>
int main()
{
int i;
printf("%d \n",'\1');
printf("%d \n",'\022');
printf("%d ",'\555');
return 0;
}

Output: 1 18 109

When we compile this program then gcc compiler gives warning '\555' is octal escape sequence out of range? What is this range?


Solution

  • The upper limit is usually 255, which is '\377'. This assumes an eight-bit char type, which is not guaranteed by C, but is a safe assumption in most environments.