I\'m trying to print escape characters as characters or strings using this code:
while((c = fgetc(fp))!= EOF)
{
if(c == \'\\0\')
{
printf(\"
For that we need to use double backslash.
Examples:
if(c == '\0')
{
printf(" \\0");
}
else if(c == '\a')
{
printf(" \\a");
}
else if(c == '\b')
{
printf(" \\b");
}
else if(c == '\f')
{
printf(" \\f");
}
else if(c == '\n')
{
printf(" \\n");
}
else if(c == '\r')
{
printf(" \\r");
}
else if(c == '\t')
{
printf(" \\t");
}
else if(c == '\v')
{
printf(" \\v");
}
Should work for you!