C Newbie, ascii control function

Posted by user570607 on Stack Overflow See other posts from Stack Overflow or by user570607
Published on 2011-01-11T00:48:19Z Indexed on 2011/01/11 0:53 UTC
Read the original article Hit count: 154

Filed under:

Hey there,

I have written a program that works well in C that converts non-readable ASCII to their character values. I would appreciate if a C master? would show me a better way of doing it that I have currently done, mainly this section:

if (isascii(ch)) { switch (ch) { case 0: printControl("NUL"); break; case 1: printControl("SOH"); break;

    .. etc (32 in total)

    case default:
        putchar(ch);
        break;
}

} Is it normal to make a switch that big? Or should I be using some other method (input from an ascii table?)

© Stack Overflow or respective owner

Related posts about c